3

我必须编写一个 XPath 表达式来获取 HTML 波纹管中锚标记的 href 属性,该属性紧跟标记为“当前页面”的标记(在示例中为 #notimportant/2)。

<dd>
    <a href="#notimportant/1" class="current-page">1</a>
    <a href="#notimportant/2">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>

我想过从 //a[@class='current-page']/../next-sibling-of-first-node/@href 之类的东西开始,但我被困在这里......

有人可以帮我解决这个问题吗?我搜索了一下,但 XPath 不是我最喜欢的技能(不,我不能使用 jQuery。它不是 web 应用程序)。

4

1 回答 1

8
//a[@class='current-page']/following-sibling::a[1]
于 2010-02-04T10:53:40.830 回答