我必须编写一个XPath表达式来获取html标记中的锚标记的href属性,该标记紧跟在标记为“当前页”的标记之后(在示例中#notimportant/2)。使用XPath选择下一个链接
<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应用程序)。
你是什么意思return empty?如果没有下一个兄弟,它通常会返回null。 – 2010-02-04 11:46:11
对不起,你可以看到我是一个XPath noob。 我只想返回下一个元素,如果它的href不以“/ last”结尾的话。否则,我希望表达式返回null。 – Pablo 2010-02-04 12:03:45