I’ve got an XML that I’m trying to transform which contains a relation between different nodes, related via ID, but I can’t figure out how to ‘glue’ them together.
XML example:
<order>
<products>
<product id="1234">
<item quantity="5" colour="red">
<item quantity="2" colour="blue">
</product>
<product id="9876">
<item quantity="10" colour="teal">
</product>
</products>
<prices>
<productprice>
<refProduct id="1234" />
<price gross="9.99" />
</productprice>
<productprice>
<refProduct id="9876" />
<price gross="6.89" />
</productprice>
</prices>
</order>
My desireable outcome would be something like being able to display the products via a for-each, with their respective prices listed next to them.
Any clues gratefully received.
EDIT: fixed renegade products element, example should be well formed
Here is a simple proof of concept for making the connection you wanted. The input XML wasn’t well formed so I made the assumption there was only one products element, with multiple product children.
It results in the following output: