473,394 Members | 1,645 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,394 software developers and data experts.

Uniquely Merging XML files

I was easily able to merge 2 XML files using the guide at
http://support.microsoft.com/kb/311530/EN-US/. However, the two XML files may
contain duplicate tags. Is there an easy way to merge so that I do not have
duplicate tags in the final document? The format of my XML files are as
follows:

<Products>
<Product Name="Some Product">
<Versions>
<Version Value="V02.07.00B ">
<NewFeatures>
<NewFeature id="4324" Value="Added capability to display
thermocouple values in deg C." />
</NewFeatures>
<Fixes>
<Fixed id="4487" Value="Corrected memory issue in transmitting EGD
packets." />
</Fixed>
</Fixes>
</Version>
<Version Value="V02.06.03C ">
<Fixes>
<Fixed id="4505" Value="Corrected problem where I/O packs wouldn't
wait for IP address from DHCP when firmware wasn't loaded." />
</Fixes>
</Version>
</Versions>
</Product>
</Products>

It is an XML file containing release notes. If 2 XML files are merged which
both have a "Fixed" or "NewFeature" tag with the same id and value
attributes, and in the same version and product tag as one in the current
file, then it should not list the tag twice.

The code I'm using is:

XmlTextReader xmlreader1 = new XmlTextReader("1.xml");
XmlTextReader xmlreader2 = new XmlTextReader("2.xml");
DataSet ds = new DataSet();
ds.ReadXml(xmlreader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xmlreader2);
ds.Merge(ds2, false, MissingSchemaAction.Add);
ds.WriteXml("1-2.xml");
Nov 17 '05 #1
1 6988
Ryan,

Unfortunately, there is no easy way to do this. You will have to cycle
through the merged documents and remove the duplicates yourself.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ryan" <Ry**@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
I was easily able to merge 2 XML files using the guide at
http://support.microsoft.com/kb/311530/EN-US/. However, the two XML files
may
contain duplicate tags. Is there an easy way to merge so that I do not
have
duplicate tags in the final document? The format of my XML files are as
follows:

<Products>
<Product Name="Some Product">
<Versions>
<Version Value="V02.07.00B ">
<NewFeatures>
<NewFeature id="4324" Value="Added capability to display
thermocouple values in deg C." />
</NewFeatures>
<Fixes>
<Fixed id="4487" Value="Corrected memory issue in transmitting
EGD
packets." />
</Fixed>
</Fixes>
</Version>
<Version Value="V02.06.03C ">
<Fixes>
<Fixed id="4505" Value="Corrected problem where I/O packs
wouldn't
wait for IP address from DHCP when firmware wasn't loaded." />
</Fixes>
</Version>
</Versions>
</Product>
</Products>

It is an XML file containing release notes. If 2 XML files are merged
which
both have a "Fixed" or "NewFeature" tag with the same id and value
attributes, and in the same version and product tag as one in the current
file, then it should not list the tag twice.

The code I'm using is:

XmlTextReader xmlreader1 = new XmlTextReader("1.xml");
XmlTextReader xmlreader2 = new XmlTextReader("2.xml");
DataSet ds = new DataSet();
ds.ReadXml(xmlreader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xmlreader2);
ds.Merge(ds2, false, MissingSchemaAction.Add);
ds.WriteXml("1-2.xml");

Nov 17 '05 #2

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

Similar topics

5
by: Stefan Franke | last post by:
Hi, I would like to merge two XML files. The first XML contains a list of books, the second XML file contains a bestseller list of books. So some of the books in the first file will appear in the...
2
by: Cy Huckaba | last post by:
I have an XML document that is linked to other document and I can't figure out what the best way to try and merge them before query qith an XpathNavigator. Simple example...a root xml document...
3
by: Mike | last post by:
Hi! I also asked this question in C# group with no results: I have 2 datasets loaded with data from two xml files having the same schema. The files contain data from yesterday and today. I'd...
2
by: Nikhil Prashar | last post by:
I'm trying to merge two XML files that have the same structure but not necessarily the same nodes in the same order. I've tried opening the files as datasets and using the DataSet.Merge() function,...
10
by: n o s p a m p l e a s e | last post by:
Is it possible to merge two DLL files into one? If so, how? Thanx/NSP
1
by: adamrace | last post by:
Hi, I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
0
by: veer | last post by:
Hello sir. I am making a program on merging in Visual Basic. The program is that I have a folder which is not on my hard drive contain 80 Mdb files and each Mdb file contains two tables. I want to...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.