Hi ashishmagneti
XML comparison is no easy task, and especially when it comes to writing your own diff tool. The Microsoft already has a tool which does exactly comparing: Diff two XML files and give me back the differences.
You will first need to download the assembly
here[
^] to use the tool.
I'll go ahead and jump into some code which does a very basic comparison of two different files of xml, and returns the difference to an XMLWriter:
using Microsoft.XmlDiffPatch;
The code is then very simple:
System.Xml.XmlWriter xml_writer = System.Xml.XmlWriter.Create("C:\diff.xml");
XmlDiff diff =
new XmlDiff(XmlDiffOptions.IgnoreChildOrder |
XmlDiffOptions.IgnoreComments |
XmlDiffOptions.IgnoreWhitespace);
diff.Compare("C:\file1.xml",
"C:\file2.xml",
true,
xml_writer);
Regards,
Alex