Deep Deep - 3 months ago 10
Java Question

using xpath fetch top level list of nodes having specific attribute

Please provide me X-path expression for the below scenario.

The Element Tag name are not constant they can vary , also the hierarchy may vary as in the above case the path attribute is present at level 1, there might be a case it is not present at level 1 but below that.

Expected Result : NodeList nodeList = { a,z}; list should not contain the b or y nodes

<a path="a">
<b path="b"></b>
<z path="z">
<y path="y"></y>


Simply as this:



If the root name is not a constant: