florinstefan.bambarac@gmail.com

Merge/Split XML to result in multiple documents depending on specific XML element

Discussion created by florinstefan.bambarac@gmail.com on Mar 28, 2018

Hello all,

 

This might come off as a very basic request - however i cannot think very clearly at this point - so i'm asking outside help.

 

I have one single document, which i need to split into multiple documents, depending on how many times a specific XML element changes its value.

 

Use Case:

<Baskets>
<Basket>
<Item>
<El1>
<El2>
<AddressId>1</AddressId>
<El3>
</Item>
<Item>
<El1>
<El2>
<AddressId>1</AddressId>
<El3>
</Item>
<Item>
<El1>
<El2>
<AddressId>10</AddressId>
<El3>
</Item>
</Baskets>
</Basket>

 

From the above - i would like to have 2 separate documents returned - which would contain all of the information filtered by the AddressId - as seen below:

 

Document 1:

<Baskets>
<Basket>
<Item>
<El1>
<El2>
<AddressId>1</AddressId>
<El3>
</Item>
<Item>
<El1>
<El2>
<AddressId>1</AddressId>
<El3>
</Item>

</Baskets>
</Basket>

 

Document 2:

 

<Baskets>
<Basket>

<Item>
<El1>
<El2>
<AddressId>10</AddressId>
<El3>
</Item>
</Baskets>
</Basket>

 

Tried splitting the document on the AddressId - which works out perfectly - however, putting it back together results in one single file, as opposed to the multiple files i am looking for.

 

Any ideas are welcome.

Thank you!

Stefan.

Outcomes