tags:

views:

365

answers:

2

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

For example:

<nodes>
    <node attribute1="aaaa"></node>
    <node attribute1="bbbb"></node>
    <node></node> <- FIND THIS
</nodes>
+9  A: 
//node[count(@*)=0]

Will select all <node> with zero attributes

erik
+11  A: 
//node[not(@*)]

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

48klocs
+1 - That's the more XPath-y solution. :)
Tomalak