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");