Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath: How to select nodes which have no attributes?

Tags:

xpath

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> 
like image 562
Zanoni Avatar asked Aug 24 '09 17:08

Zanoni


People also ask

How many types of nodes are there in XPath specification?

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.


1 Answers

//node[not(@*)] 

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

like image 68
48klocs Avatar answered Oct 22 '22 02:10

48klocs