让我们假设有一个像这样的XML格式:
我们要如何选择具有 名称 属性和至少一个非空的 译者 节点的书架节点?
基本的XPath教程没有提供这么复杂的例子。
<bookshelf>
<cathegory name = "Programming" />
<book name = "Tille 1" >
<author>....</author>
</book>
<book name = "Tille 2" >
<author>....</author>
<translator></translator>
</book>
<book name = "Tille 3" >
<author>....</author>
<translator>John D.</translator> <!-- non-empty nodes are acceptred! -->
</book>
</bookshelf>
我们要如何选择具有 名称 属性和至少一个非空的 译者 节点的书架节点?
基本的XPath教程没有提供这么复杂的例子。
[cathegory/@name and .//translator/text()]
怎么样? - choroba