473,669 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.0 0B ">
<NewFeatures>
<NewFeature id="4324" Value="Added capability to display
thermocouple values in deg C." />
</NewFeatures>
<Fixes>
<Fixed id="4487" Value="Correcte d memory issue in transmitting EGD
packets." />
</Fixed>
</Fixes>
</Version>
<Version Value="V02.06.0 3C ">
<Fixes>
<Fixed id="4505" Value="Correcte d 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(xmlr eader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xml reader2);
ds.Merge(ds2, false, MissingSchemaAc tion.Add);
ds.WriteXml("1-2.xml");
Nov 17 '05 #1
1 7024
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.co m

"Ryan" <Ry**@discussio ns.microsoft.co m> wrote in message
news:BD******** *************** ***********@mic rosoft.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.0 0B ">
<NewFeatures>
<NewFeature id="4324" Value="Added capability to display
thermocouple values in deg C." />
</NewFeatures>
<Fixes>
<Fixed id="4487" Value="Correcte d memory issue in transmitting
EGD
packets." />
</Fixed>
</Fixes>
</Version>
<Version Value="V02.06.0 3C ">
<Fixes>
<Fixed id="4505" Value="Correcte d 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(xmlr eader1);
DataSet ds2 = new DataSet();
ds2.ReadXml(xml reader2);
ds.Merge(ds2, false, MissingSchemaAc tion.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
4554
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 second file. I want to merge the two files, so that the ones, that also exist in the second XML file are printed in bold. I am trying to compare the titles of the books, but this doesn't seem to work. Could anybody give me a hint how to solve...
2
3586
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 contains the root folder that can contain items and other folders. The other folders can either live in the root document or be in other xml files completely (to make it easier for multiple developers/processes to work on the data at the same time.) ...
3
11016
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 like to merge both datasets in such a way that the resulting dataset should have all the today's data overriding yestrerday's data. CATCH: the today's dataset contains only the daily changes (DELTA) and merging should not remove all unchanged...
2
3891
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, but this only "fumbles" the data together and puts children under the wrong parent nodes. How else could I go about merging the files? I'm using C# .NET.
10
10054
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
2391
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 what the best way of going about merging the two files together, with the old price and the new price using the ID's. The second file has a list of all the products on their system, the first has just a few of these which are on the other system. If...
10
4497
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 consideration here is that it is supplied to the AsyncOperationManager.CreateOperation(userSuppliedState) method... with userSuppliedState being, more or less, a taskId. In this case, the userSuppliedState {really taskId} is of the object type,...
0
1342
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 merge all the Mdb files into a new Mdb file using a single execution or in one loop. I have some coding, please correct it or modify. I don't know how to move from one database to another. Set dbparent = Workspaces(0).OpenDatabase(txtparentMDBFile)...
0
2346
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 single-sheet xls files, but I agree it's nicer if the programs works in other cases too. -and no, I don't intend to use data fields. Wouldn't it be easier to convert those to string values if I ever came across them? Thanks again! Albert-Jan
0
8383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8894
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.