By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,034 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,034 IT Pros & Developers. It's quick & easy.

Merging two XML Files

P: n/a
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.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nikhil Prashar wrote:
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.


This depends on your schema.
If it is very simple, you could use two 'XmlReader's, read from them and
write that data into one XmlWriter.
For example this:
<root>
<item id="234"><some/><data/></item>
...
</root>

You just read all the nodes from the two files, ignore the root-Elements
and write them into the new file into a newly created root-Element...

For more complex files you could maybe use XSLT...
--
Pascal Schmitt
Nov 12 '05 #2

P: n/a
Nikhil Prashar wrote:
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.


http://www.gotdotnet.com/team/xmltools/default.aspx may help.

Cheers,

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.