glmxndr
glmxndr

Reputation: 46586

XPATH 1.0 : match not empty elements

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 ?

Upvotes: 2

Views: 4216

Answers (1)

Tomalak
Tomalak

Reputation: 338228

You were close - it is node(), not nodes():

.//myelem[count(node()) = 0]

or, more idiomatically:

.//myelem[not(node())]

Upvotes: 5

Related Questions