Friday, August 30, 2013

I have two XML documents, identical in structure. If a element value in A is different than B, then it needs to be copied to B (or a copy of B).

If the xml structure is simple, I think you could just compare the two xmls by enumerating the xml element in your code.


Here's a topic from MSDN which will give you help:


http://msdn.microsoft.com/en-us/library/bb387050.aspx


If the xml structure is complex, and the xml content is large, maybe XmlDiffPatch is what you want:


http://msdn.microsoft.com/en-us/library/aa302294.aspx


Code sample:



using Microsoft.XmlDiffPatch;
//Create another xml to store the difference between the two xmls.
System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create("C:\diff.xml");
// There are a number of available options in the XmlDiffOptions enum
XmlDiff diff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreWhitespace);
diff.Compare("C:\temp1.xml", "C:\temp2.xml", true, writer);

Please search on line, more information will come up.



Caillen

<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>

Thanks

MSDN Community Support



Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


No comments:

Post a Comment