如何在xpath查询中选择最后一项?
我是xpath新手,我了解如何在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和
/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之间的每个节点,而不仅仅是最后一个节点。