How can I merge multiple xml nodes of the same type into one node?



I have a fairly big xml doc that looks like:



<products>
<product>
<id>1</id>
<other>y</other>
<notarget>x</notarget>
<target>num1</target>
<target>num2</target>
<target>num3</target>
</product>
</products>


But I need it to look like:



<products>
<product>
<id>1</id>
<other>y</other>
<notarget>x</notarget>
<target>num1,num2,num3</target>
</product>
</products>


I don't have much experience with xml so I'm not even sure what technologies to use to go through the file to make these changes. There can be more than one product but this example just has one. I'm using python but I can also use a shell.


No comments:

Post a Comment