Hi guys, i'm a little bit new to c# but someone asked me to make something for him,

now was the question to make a Winform application, and you can insert 2 xml files, then read the xml files,

and make a new xml file with the updated data out of the 2 xml files,

so my question is if someone can help me a little bit out of this.

Do both XML files follow the same schema?

It will be close to impossible to merge two different schemas without another schema defining what the merged output should look like.

You can't just take two arbitrary XML files and merge them ^^

nope same schemas! i think you mean with <name> etc etc ?

Yes, pretty much.

There are two primary ways to do this.

  1. Create a similar hierarchical structure in classes and copy each XML file into a single structure, then copy it back out again.
  2. Read each file at the same time section by section, using XPath, then write out the data into a new XML file in real-time.

I prefer method 1, simply because it gives me an easier way to debug content going through the system. However, this will be slower and use more memory.
Method 2 should garner much better performance but you lose a lot of the ease of debugging.

The choice is yours :)