syntax - How to select all leaf nodes using XPath expression? -


i believe it's possible couldn't figure out syntax. this:

xmlnode.selectnodes("//*[count(child::*) <= 1]") 

but not correct.

use:

//node()[not(node())] 

in case element leaf nodes wanted (and needs clarification -- elements have non-element children considered leaf nodes?), following xpath expression selects them:

//*[not(*)] 

both expressions above shortest select desired nodes (either any-node or element -- leaf nodes).


Comments