Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
如何在xpath查询中选择最后一项?_Xpath - Fatal编程技术网

如何在xpath查询中选择最后一项?

如何在xpath查询中选择最后一项?,xpath,Xpath,我是xpath新手,我了解如何在xpath中获取一系列值: /bookstore/book[position()>=2 and position()<=10] /bookstore/book[position()>=2和position()您可以使用表示上下文中最后一项的last(): /bookstore/book[position()>=2 and position() <= (last() - 1)] /bookstore/book[position()>=2和

我是xpath新手,我了解如何在xpath中获取一系列值:

/bookstore/book[position()>=2 and position()<=10]

/bookstore/book[position()>=2和position()您可以使用表示上下文中最后一项的
last()

/bookstore/book[position()>=2 and position() <= (last() - 1)]

/bookstore/book[position()>=2和position()
/bookstore/book[position()>=2和position()@helderdarocha成功了!!!你能帮我一个忙并把它作为答案让我接受吗?非常感谢!谢谢,再试一次,它成功了。非常感谢。无法使用这种方法取回它应该是
/bookstore/book[position()=(last()-1)]
?因为这个公认的答案确实包括索引2和N-1之间的每个节点,而不仅仅是最后一个节点。