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:
<?xml version="1.0" encoding="utf-8"?>
<customer ID="A0001" name="customername">
.....
.....
</customer>
Source xml:
<?xml version="1.0" encoding="utf-8"?>
<order number="00001">
<.....>
<.....>
<.....>
</order>
Every source xml file needs to be inserted between <customer ...>
and </customer>
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
string myOrder = textReader.ReadOuterXml();
writer.WriteRaw(myOrder );
Result (where every order is a different xml file)
<?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>
But i'm afraid of out of memory exeptions for the large files using ReadOuterXml().
Any suggestion ?