Reputation: 797
Hi below is my input XML I want to spit the XML by row:
<root>
<row>
<Product>abc</Product>
<price>20</price>
<discount>10%</discount>
</row>
<row>
<Product>def</Product>
<price>120</price>
<discount>11%</discount>
</row>
<row>
<Product>ghi</Product>
<price>210</price>
<discount>5%</discount>
</row>
</root>
The output XML should look like below:
First XML
<trx>
<Product>abc</Product>
<discount>10%</discount>
</trx>
Second XML
<trx>
<Product>def</Product>
<discount>11%</discount>
</trx>
And so on.
Do I have to use splitter or xslt what will be the xslt code to achieve this. I need to change the root name and also remove the field price from the original XML
Upvotes: 1
Views: 196
Reputation: 797
The best way I found was using a splitter and then using a data mapper to change the structure. So I used the splitter first and using xpath I took the row
#[xpath('/root/*')]
Then i used the data mapper to change it to my desired format
Upvotes: 1