Hi

I have 2 XML files of similar structure and I have requirement to merge them in a way, that Elements with same ID are replaced.

For Example:

If first file is Book1.xml with the following information:

Code:
<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
   </book>
   <book id="bk102">
      <author>Jeanette, Dasha</author>
      <title>Quack the Duck</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
   </book>
</catalog>
And Book2.xml is:

Code:
<?xml version="1.0"?>
<catalog>
<book id="bk102">
      <author>Randall, Cynthia</author>
      <title>Lover Birds</title>
      <genre>Romance</genre>
      <price>4.95</price>
   </book>
   <book id="bk103">
      <author>Vinzovskaia, Irina</author>
      <title>Piano Fort A</title>
      <genre>Romance</genre>
      <price>4.95</price>
   </book>
</catalog>
Then the merged file, say Book3.xml would be:

Code:
<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
   </book>
   <book id="bk102">
      <author>Randall, Cynthia</author>
      <title>Lover Birds</title>
      <genre>Romance</genre>
      <price>4.95</price>
   </book>
   <book id="bk103">
      <author>Vinzovskaia, Irina</author>
      <title>Piano Fort A</title>
      <genre>Romance</genre>
      <price>4.95</price>
   </book>
</catalog>
I have to do it in C#.

Code Source: http://support.microsoft.com/kb/311530

I tried doing the solution provided here but the resultant file has 2 values with the same ID.

So, how to go about it?