.net - Finding all nodes without any text node -
with xpath (.net), i'm trying select nodes don't contain text node.
given document:
<root> <node1> <node1a>node 1a</node1a> </node1> <node2>node 2</node2> <node3> <node3a>node 3a</node3a> <node3b></node3b> </node3> <node4></node4> <node5> <node5a></node5a> </node5> </root>
i'm tyring nodes:
<node3b></node3b> <node4></node4> <node5> <node5a></node5a> </node5>
note overlapping subtrees merged, node5a should not returned separately.
i expect pull trick, reason (which obvious when points out) doesn't:
//*[count(//text()) = 0]
note: i'm using xpath tester try things out.
assuming result example want (which not totally in accordance statement in title) suggestions above
//*[count(.//text()) = 0]
or preferred way
//*[not(.//text())]
doesn't work result not expected
<node3b /> <node4 /> <node5> <node5a /> </node5> <node5a /> <!-- node not present in example -->
if want subtrees without text node not included in other resulting subtrees solution 1
//*[not(.//text())][not(ancestor::*[not(.//text())])]
the second predicate remove result nodes has @ least 1 ancestor included in result
Comments
Post a Comment