merge xml files in C#

haultussy

New Member
I'd like to merge a few xml files.The destination xml is slightly different then the source files. The destination file contains an aditional root element.For example.The destination xml:
\[code\]<?xml version="1.0" encoding="utf-8"?><customer ID="A0001" name="customername">..........</customer>\[/code\]
Source xml:
\[code\]<?xml version="1.0" encoding="utf-8"?><order number="00001"> <.....> <.....> <.....></order>\[/code\]Every source xml file needs to be inserted between \[code\]<customer ...>\[/code\] and \[code\]</customer>\[/code\]The source files can be very large (e.g. 2 Gb).I can write the destination xml file with the root element and read the source files using XmlTextReader and
\[code\]string myOrder = textReader.ReadOuterXml(); writer.WriteRaw(myOrder );\[/code\]

Result (where every order is a different xml file)
\[code\]<?xml version="1.0" encoding="utf-8"?><customer ID="A0001" name="customername"> <order number="00001"> <.....> <.....> <.....> </order> <order number="00002"> <.....> <.....> <.....> </order> <order number="00003"> <.....> <.....> <.....> </order></customer>\[/code\]
But i'm afraid of out of memory exeptions for the large files using ReadOuterXml().Any suggestion ?
 
Back
Top