问题
I need to match elements that contain neither PCDATA nor child elements.
I tried this:
.//myelem[count(nodes())=0]
but nodes() is unknown in XPATH 1.0.
What is the most concise way that you know of to do this in XPATH 1.0 ?
回答1:
You were close - it is node(), not nodes():
.//myelem[count(node()) = 0]
or, more idiomatically:
.//myelem[not(node())]
来源:https://stackoverflow.com/questions/1914085/xpath-1-0-match-not-empty-elements