XPath:如何选择没有属性的节点? [英] XPath: How to select nodes which have no attributes?

查看:32
本文介绍了XPath:如何选择没有属性的节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用XPath,如何选择没有属性的节点(其中属性计数=0)?

Using XPath, how to select nodes which have no attributes (where attribute count = 0)?

例如:

<nodes>
    <node attribute1="aaaa"></node>
    <node attribute1="bbbb"></node>
    <node></node> <- FIND THIS
</nodes>

推荐答案

//node[not(@*)]

这是选择文档中所有名为node"的节点的 XPath,没有任何属性.

That's the XPath to select all nodes named "node" in the document without any attributes.

这篇关于XPath:如何选择没有属性的节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆