"Merging" XML in C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
So, I have two XML files, structure like the below, data changed to protect the innocent:
data.xml
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; strings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; id<span style="color:Blue; >123<span style="color:Blue; </<span style="color:#A31515; id<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >STR_NAME1<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; body<span style="color:Blue; >The purple dog.<span style="color:Blue; </<span style="color:#A31515; body<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; id<span style="color:Blue; >125<span style="color:Blue; </<span style="color:#A31515; id<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >STR_OBJ<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; body<span style="color:Blue; >The green handbag.<span style="color:Blue; </<span style="color:#A31515; body<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; strings<span style="color:Blue; >
[/code]
data_extracted.xml
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; strings<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; id<span style="color:Blue; >123<span style="color:Blue; </<span style="color:#A31515; id<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >STR_NAME1<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; body<span style="color:Blue; >The purple ocelot.<span style="color:Blue; </<span style="color:#A31515; body<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; string<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; strings<span style="color:Blue; >
[/code]
<br/>
Note that in the second file, the body has changed for id 123.
Im trying to figure out the most expedient method to update the data in data.xml with the updates from data_extracted.xml and save it back to data.xml (Im pretty sure that last bit is just going to be save to xml.tmp, rename original, rename .tmp, delete
renamed original, so you can ignore that, unless its just Thats how it works). Ive tried datasets, xdocuments, xmldocuments.. nothing seems to actually work.
The data.xml files range from 17MB at largest (2nd largest is 5mb, so the dropoff is quick) to 100k. The extracted are all tiny.
Any suggestions are useful.

View the full article
 
Back
Top