I have a XML payload that contains the following example:
<Example>
<Brand>
<Id>987S</Id>
<logo>circle</logo>
<Item>
<Name>cologne1</Name>
<Item>
<Name>Bosque</Name>
</Item>
</Item>
<Item>
<Name>t-Shirt</Name>
</Item>
</Brand>
<Brand>
<Id>877823C</Id>
<logo>circle</logo>
<Item>
<Name>t-Shirt2</Name>
<Item>
<Name>t-Shirt black</Name>
<Item>
<Name>t-Shirt black with logo</Name>
</Item>
</Item>
</Item>
</Brand>
</Example>
The XML is divided into:
- Example as root node
- Brand Objects
- Item Objects: Those Items can also contains more Items
- Brand Objects
I get this structure randomly until 3 levels in-depth per Item.
The output expected is all Items in the same level into a parent node:
<Supermarket>
<Item>
<BarValue>cologne1</BarValue>
</Item>
<Item>
<BarValue>Bosque</BarValue>
</Item>
<Item>
<BarValue>t-Shirt</BarValue>
</Item>
<Item>
<BarValue>t-Shirt2</BarValue>
</Item>
<Item>
<BarValue>t-Shirt black</BarValue>
</Item>
<Item>
<BarValue>t-Shirt black with logo</BarValue>
</Item>
</Supermarket>
Is there a way to loop the XML file dynamically with Dataweave?