A rather simple problem... XML Fragment:
<bean id='Juicer'>
<property name="electric">
<value>false</value>
</property>
</bean>
<bean id='Oven'>
<property name="electric">
<value>true</value>
</property>
<property name="wattage">
<value>1000</value>
</property>
</bean>
I'm trying to write an xpath query that will select all bean
s that do not have a <property name="wattage">
.
I cant figure out how to say "beans not having this child" in xpath.
Note that I cannot rely on the "electric" property to be false each time the "wattage" is absent. (also, this example is kinda contrived).
Thanks :)
Okay, after a little digging i figured it out:
//bean[not (property[@name='wattage'])]
Simple indeed :P
Try
//bean[not(property[@name='wattage'])]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With