468,117 Members | 2,060 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

Merging two XML Files

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
2 3606
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
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.

Similar topics

5 posts views Thread by Stefan Franke | last post: by
2 posts views Thread by Cy Huckaba | last post: by
10 posts views Thread by n o s p a m p l e a s e | last post: by
reply views Thread by Albert-jan Roskam | last post: by
10 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.