Here is the my structure:
<AllCharges>
<Charge>
<ID>1</ID>
<Type>A</Type>
</Charge>
<Charge>
<ID>2</ID>
<Type>A</Type>
</Charge>
<Charge>
<ID>3</ID>
<Type>B</Type>
</Charge>
</AllCharges>
What I want back is the full structure but I only want results in which the Type = A. The hard part I am finding is pulling back the parent xml nodes. Here is an example of what my result should look like:
<AllCharges>
<Charge>
<ID>1</ID>
<Type>A</Type>
</Charge>
<Charge>
<ID>2</ID>
<Type>A</Type>
</Charge>
</AllCharges>
I would assume the XPath would look something like this but it doesn’t work:
/AllCharges[//Type=A]
Is this possible?
That should do it.
The expression reads, “Select any Charge element whose parent is AllCharges, having a child element called Type whose text value is ‘A’.”
Tested it in the following XSLT template:
The output was: