473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Remove duplicate nodes in XML file

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.

May 24 '06 #1
3 2584
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.

da****@edazzle.net wrote:
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.

May 24 '06 #2
Or stick with XML and run a stylesheet over it.
http://www.devx.com/xml/Article/28610/0/page/4

May 24 '06 #3
Flinky Wisty Pomm wrote:
Or stick with XML and run a stylesheet over it.
http://www.devx.com/xml/Article/28610/0/page/4


Even better. :)
May 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Damien Cobbs | last post by:
Is there a way to remove duplicate rows from a table that does not have a primary key leaving one copy of the row without comparing each column to each other as suggested by the code example below:...
7
by: Voetleuce en fênsievry | last post by:
Hello everyone. I'm not a JavaScript author myself, but I'm looking for a method to remove duplicate words from a piece of text. This text would presumably be pasted into a text box. I have,...
1
by: guoqi zheng | last post by:
I have a dataset with about 20-50 records on it. Some of has the same value for a key column, those duplicates need to be removed. How can I remove duplicate itmes from a dataset???? I know...
1
by: JTreefrog | last post by:
Hello - I've read a ton of stuff about deleting duplicate values in an array. They are all very useful - they just haven't addressed an array of objects. Here's my array: var sDat = ; The...
1
by: ck | last post by:
What should I program in order to close window and remove a text file as soon as users click on "Abort" button. Thanks.
1
by: tosachinji | last post by:
Hi I am new to xslt. Could you please tell me, how can we remove duplicate records from a xml file. Here is the xml file: <Row> <Cell><Data>Active</Data></Cell> <Cell><Data>D</Data></Cell>...
5
twillie
by: twillie | last post by:
Hello, I have a linked list in C++ and I am trying to remove all duplicate nodes from the list. The code below is what our prof. wrote on the board in pusdo code in class, yet it doesn't seem to...
6
by: topala1984 | last post by:
hello all excuse my english, I`m a beginer in java and I want to remove duplicate cities + rearrenging file`s lines elements from one 150 mb file, in my file I have that: ...
1
by: ashishsinghvi | last post by:
hi ,, i have an xml document. and i want to know how to remove the duplicate nodes from xml documents. plz do some code for this. this is very urgent.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.