如何获得特定的标签?

c# html-agility-pack

我正在使用HtmlAgilityPack ,我正在尝试获取一个特定a标签,其中包含特定的文本。假设我有这个html结构:

<ul>
    <li class="current">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/">Summary</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/head2head/">H2H Comparison</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/commentary/">Commentary</a>
    </li>
    <li class=""><a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/venue/">Venue</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/map/">Map</a>
    </li>
</ul>

我想得到a包含InnerText a标签:“Venue”。其实我的想法是这样的:

<ul>
    <li class="current">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/">Summary</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/head2head/">H2H Comparison</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/commentary/">Commentary</a>
    </li>
    <li class=""><a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/venue/">Venue</a>
    </li>
    <li class="">
        <a href="/matches/2018/05/20/italy/serie-a/ss-lazio-roma/fc-internazionale-milano/2539153/map/">Map</a>
    </li>
</ul>

这是代码工作但存在另一种方式可能使用xpath或类似的东西?

一般承认的答案

这将返回包含单词“Venue” //a[contains(text(),'Venue')]所有锚标签




许可下: CC-BY-SA with attribution
不隶属于 Stack Overflow
这个KB合法吗? 是的,了解原因
许可下: CC-BY-SA with attribution
不隶属于 Stack Overflow
这个KB合法吗? 是的,了解原因