Littlebitter
Littlebitter

Reputation: 701

XPath select node that don't have specified child

<a>
   <b />
   <c />
</a>
<a1>
   <b />
</a1>

How can I select nodes, that don't have specified child node? For example I need all node, that doesn't have c node, in my example a1.

Upvotes: 3

Views: 2826

Answers (1)

dogbane
dogbane

Reputation: 274612

Given:

<root>
    <a>
        <b />
        <c />
    </a>
    <a1>
        <b />
    </a1>
</root>

Use: /root/*[not(c)]

The result is a1.

Upvotes: 6

Related Questions