Maybe someone can help me find a solution to my problem.
I need to perform an XPath query in the xml below that pulls only the "Field" nodes that are direct child nodes.
In the below example, the query should pull fields E1F1, E1F2 and E1F3.
So far I am running the query: //Field
, but I get all fields (including the ones that belong to E1_1 which I don't want).
<Entity id="E1">
<Field id="E1F1"></Field>
<Field id="E1F2"></Field>
<Field id="E1F3"></Field>
<Entity id="E1_1">
<Field id="E1_1F1"></Field>
<Field id="E1_1F2"></Field>
<Field id="E1_1F3"></Field>
</Entity>
Thank you!!
Use an absolute XPath:
/Entity/Field
//
will match anywhere. If you use a single forwardslash, the match must be exact.
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