I know that there has been a lot of questions like this but I couldn\'t find a reply that would satisfy my needs. I have to write an application that will compare XML files:
Microsoft's XML Diff and Patch API should work nicely:
public void GenerateDiffGram(string originalFile, string finalFile,
XmlWriter diffGramWriter)
{
XmlDiff xmldiff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder |
XmlDiffOptions.IgnoreNamespaces |
XmlDiffOptions.IgnorePrefixes);
bool bIdentical = xmldiff.Compare(originalFile, finalFile, false, diffGramWriter);
diffGramWriter.Close();
}
If you need to, you can also use the Patch tool to compare the files and merge them:
public void PatchUp(string originalFile, string diffGramFile, string outputFile)
{
XmlDocument sourceDoc = new XmlDocument(new NameTable());
sourceDoc.Load(originalFile);
using (var reader = XmlReader.Create(diffGramFile))
{
XmlPatch xmlPatch = new XmlPatch();
xmlPatch.Patch(sourceDoc, reader);
using (var writer = XmlWriter.Create(outputFile))
{
sourceDoc.Save(writer);
writer.Close();
}
reader.Close();
}
}