Remove duplicate nodes in XML file

D

dazzle

I have an XML file and I would like to remove duplicate nodes within it
but I can't get my head round on how to do this.

Example XML file:

<root>

<plugin>
<title>A9</title>
<url>some url</url>
<number>0001</number>
</plugin>

<plugin>
<title>A9</title>
<url>some url</url>
<number>0002</number>
</plugin>

<plugin>
<title>BBC</title>
<url>some url</url>
<number>0003</number>
</plugin>

</root>

End up with:

<root>

<plugin>
<title>A9</title>
<url>some url</url>
<number>001</number>
</plugin>

<plugin>
<title>BBC</title>
<url>some url</url>
<number>003</number>
</plugin>

</root>

Any help and/or code samples would be useful.
 
R

Ray Booysen

By duplicate I'm guessing you mean where the titles are the same.

Create a list and loop through all your nodes. in the loop place the
title node into the list. If there is already a node with this title,
remove the current item from the xml file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top