I need some help. I have this xml document:
<?xml version="1.0" encoding="utf-8"?>
<MyItems>
<Parent upc="A00000000000000000000001" sku="" archivo="pantalon1.jpg">
<Child upc="101" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
<Child upc="102" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
</Parent>
<Parent upc="A00000000000000000000002" sku="" archivo="image##.jpg">
<Child upc="101" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
<Child upc="102" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
</Parent>
<Parent upc="200" sku="" archivo="image##.jpg">
<Child upc="201" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
<Child upc="202" sku="" archivo="image##.jpg">
<GrandChild archivo="image##.jpg" />
</Child>
</Parent>
</MyItems>
Then, I’m trying to select all the ‘Parents’ where a ‘Child’ fulfils a condition. Example, all the parents which contains a child where, child attribute upc is equal to 101
I was studying this article:
Select nodes based on properties of descendant nodes
But I just can’t get what I want.
So what the query does is select all descendant elements named
Parentwhere any of its child elements namedChildhave an attribute namedupcthat is equal to the target upc value,targetUpc. Hopefully you should be able to follow that.