Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
Html 最后一个的XPath表达式<;a>;元素,其;href";属性以数字开头?_Html_Xml_Xpath - Fatal编程技术网

Html 最后一个的XPath表达式<;a>;元素,其;href";属性以数字开头?

Html 最后一个的XPath表达式<;a>;元素,其;href";属性以数字开头?,html,xml,xpath,Html,Xml,Xpath,我想找到一个XPath表达式,当应用于以下位置的页面时: https://ftp.opera.com/pub/opera-beta/ 将返回其href属性值以数字开头的最后一个元素的文本 如果我只是想要最后的元素,我可以简单地写: //body/pre/a[last()]/text() 但不幸的是,此页面上的最后一个元素如下所示: <a href="info/">info/</a> 那么,我可以使用什么样的XPath表达式来返回以数字开头的最后一个值呢?如果使用(//a

我想找到一个XPath表达式,当应用于以下位置的页面时:

https://ftp.opera.com/pub/opera-beta/ 将返回其
href
属性值以数字开头的最后一个
元素的文本

如果我只是想要最后的
元素,我可以简单地写:

//body/pre/a[last()]/text() 但不幸的是,此页面上的最后一个元素如下所示:

<a href="info/">info/</a>

那么,我可以使用什么样的XPath表达式来返回以数字开头的最后一个值呢?

如果使用
(//a[number(substring(@href,1,1))=number(substring(@href,1,1)))][last()]
您使用
href
属性选择文档中最后一个
元素,其中第一个字符是数字。

!“(//body/pre/a[number(substring(@href,1,1))=number(substring(@href,1,1)))[last()]/text()”查找我要查找的确切文本。非常感谢。@gepree,那么这个答案可以被接受为答案,而不仅仅是感谢。
<a href="41.0.2353.30/">41.0.2353.30/</a>