I am an XPath newbie and I trying to write a query.
I have the below xml
<P C="24709" O="2019307">
<E C="1" O="1" W="True">
<A C="11" V="11" />
<A C="12" V="12" />
<A C="13" V="13" />
</E>
<E C="1" O="2" W="True">
<A C="11" V="21" />
<A C="12" V="22" />
<A C="13" V="23" />
</E>
<E C="1" O="3" W="True">
<A C="11" V="31" />
<A C="12" V="32" />
<A C="13" V="33" />
</E>
<E C="1" O="4" W="True">
<A C="11" V="41" />
<A C="12" V="42" />
<A C="13" V="43" />
</E>
<E C="1" O="5" W="True">
<A C="11" V="51" />
<A C="12" V="52" />
<A C="13" V="53" />
</E>
<A C="24606" V="" />
</P>
I am trying to write an XPath which matches the following:
- E element with a C attribute = 1
- Which contains an A element with attributes equal to the following:
- ((C= 11 and V=11) and (C= 12 and V=12) and (C= 13 and V=13))
In the above example, the first E element node would be returned.
This code is sort of what I want:
//E[@C='1']/A[(@C='11' and @V='11') or (@C='12' and @V='12') or
(@C='13' and @V='13')]
However, this XPath returns values if (@C='13' and @V='13')] is change
to (@C='13' and @V='')]
Basically, I want all or nothing.
I thought the following code would work but it does not:
//E[@C='1']/A[(@C='11' and @V='11') and (@C='12' and @V='12') and
(@C='13' and @V='13')]
Note: If this helps, I really do not care if I get nodes returned. I
really just want a true / false to signify a match was found.