Regarding XML Diff & Patch

Uniyah

New Member
I got the example from MSDN about how to compare two XML with XML Diff and Patch.MSDN XML Diff & PathIt is an easy example but I dont get what I expect.I have the following XMls:\[code\]<a><component>A</component><component>4</component></a>\[/code\]and \[code\]<a><component>A</component><component>5</component></a>\[/code\]Running the tool code I dont get exaclty the difference. The output which I get is:\[code\]<a><component>A</component><component>5</component></a>\[/code\]But for my purposes I would like to get just the difference which differs from the original, in this case. \[code\]<a><component>4</component></a>\[/code\]Does anyone know how I can adapt the code to my solution.Thank you very much.edit code used:
  • (Here I find out the differences between the files)\[code\]public void GenerateDiffGram(string originalFile, string finalFile, XmlWriter diffGramWriter){ XmlDiff xmldiff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnoreNamespaces | XmlDiffOptions.IgnorePrefixes); bool bIdentical = xmldiff.Compare(originalFile, newFile, false, diffgramWriter); diffgramWriter.Close();}\[/code\]
  • Patching up the original file to create the new changed file.\[code\]public void PatchUp(string originalFile, String diffGramFile, String OutputFile){XmlDocument sourceDoc = new XmlDocument(new NameTable());sourceDoc.Load(originalFile);XmlTextReader diffgramReader = new XmlTextReader(diffGramFile);xmlpatch.Patch(sourceDoc,diffgramReader);XmlTextWriter output = new XmlTextWriter(OutputFile,Encoding.Unicode);sourceDoc.Save(output);output.Close();}\[/code\]
 
Back
Top