我有一个类似XML
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>Vaidyanathan Nagarajan</author>
</book>
<book category="it" cover="paperback">
<title lang="en">Learning XML</title>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
当我评估XPATH时 / bookstore / book / author / parent :: book
我得到结果:
/bookstore[1]/book[1]
/bookstore[1]/book[2]
但是由于第二个节点具有三个-node,所以我正在寻找一个XPATH表达式,该表达式使我获得以下信息:
/bookstore[1]/book[1]
/bookstore[1]/book[2]
/bookstore[1]/book[2]
/bookstore[1]/book[2]
这可能吗?
谢谢 问候 马里奥
答案 0 :(得分:0)
我有一个解决方案,XPATH
//author!parent::book/path()
返回:
/Q{}bookstore[1]/Q{}book[2]
/Q{}bookstore[1]/Q{}book[2]
/Q{}bookstore[1]/Q{}book[2]
/Q{}bookstore[1]/Q{}book[2]
谢谢 问候 马里奥