下面是我的XML:
<bookstore>
<book>
<title>Python</title>
<price>29.99</price>
</book>
<book>
<title>XML</title>
<price>29.99</price>
<feature>
<description>Learn XML</description>
</feature>
</book>
</bookstore>
如果description
"Learn XML"
匹配,则它应返回title
"XML"
。
发布于 2018-06-20 04:30:28
尝试此XPath
//description[text() = 'Learn XML']/../../title
它将所有description
元素与"Learn XML“的text()
内容进行匹配,并获得其title
。
发布于 2018-06-20 04:39:15
这个XPath,
//book[feature/description="Learn XML"]/title
将返回feature/description
为"Learn XML"
的书籍的title
元素。
https://stackoverflow.com/questions/50936407
复制相似问题