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>
In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document nodes. XML documents are treated as trees of nodes. The topmost element of the tree is called the root element.
//node[not(@*)]
That's the XPath to select all nodes named "node" in the document without any attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With