开发者

Selecting the next link using XPath

I have to write an XPath expression to get the href attribute of the anchor tag in the html bellow that comes right after the one that is marked as "current-page" (in the example #notimportant/2).

<dd>
    <a href="#notimportant/1" class="current-page">1</a>
    <a href="#notimportant/2">开发者_如何学Python;2</a>
    <a href="#notimportant/3">3</a>
    <a href="#notimportant/4">4</a>
    <!-- EDIT: Do not return the next sibling if @href ends with /last -->
    <a href="#notimportant/last">last</a>
</dd>

I thought about starting with something like //a[@class='current-page']/../next-sibling-of-first-node/@href but I am stuck here...

Could anyone help me with this one? I have googled around but XPath is not my favorite skill (and no, I can't use jQuery. it is not a webapp).


//a[@class='current-page']/following-sibling::a[1]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜