Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 使用XPath选择下一个链接_Xml_Parsing_Xpath_Html Parsing - Fatal编程技术网

Xml 使用XPath选择下一个链接

Xml 使用XPath选择下一个链接,xml,parsing,xpath,html-parsing,Xml,Parsing,Xpath,Html Parsing,我必须编写一个XPath表达式,以获取html bellow中锚定标记的href属性,该属性正好位于标记为“当前页面”(在示例#notimportant/2中)的属性之后 我想从像//a[@class='current-page']/../first node/@href的下一个兄弟姐妹开始,但我被困在这里了 谁能帮我做这个吗?我在谷歌上搜索过,但XPath不是我最喜欢的技能(不,我不能使用jQuery。它不是一个网络应用程序)。伙计们,你们太快了-汉克斯,伙计们。太快了。我已经编辑了我的问

我必须编写一个XPath表达式,以获取html bellow中锚定标记的href属性,该属性正好位于标记为“当前页面”(在示例#notimportant/2中)的属性之后


我想从像//a[@class='current-page']/../first node/@href的下一个兄弟姐妹开始,但我被困在这里了


谁能帮我做这个吗?我在谷歌上搜索过,但XPath不是我最喜欢的技能(不,我不能使用jQuery。它不是一个网络应用程序)。

伙计们,你们太快了-汉克斯,伙计们。太快了。我已经编辑了我的问题,你介意复习一下答案吗?什么是返回空?如果没有以下同级,它通常会返回null。对不起,您可以看到我是如何成为XPath noob的。如果下一个元素的href没有以“/last”结尾,我只想返回下一个元素。否则,我希望表达式返回null。
<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']/following-sibling::a[1]