如何读取XmlDiff.Compare()生成的diffgram文件

我正在使用XMLDiff.compare()比较两个XML文件,这是我第一次使用它并且无法弄清楚如何处理生成的diffgram文件以生成两个XML中的差异的HTML。

bool bIdentical = xmldiff.Compare(originalFile, newFile, false, diffgramWriter); 

原始文件在哪里

      ABC  100000 No Project TESTSUITE Local    PQR  1000 No Project TESTSUITE Local    ABC  1000 No Project TESTSUITE Local     

新文件是

      PQR  1000 No Project TESTSUITE Local    ABC  100000 No Project TESTSUITE Local    ABC  1000 No Project TESTSUITE Local     

生成的diffgramwriter是

            

现在使用这个需要生成HTML文件。(这是后面的部分)但是我无法正确理解(读取)diffgram文件,无法得到其含义

   

  

对于其他情况,它们在其他diffgram中更像是这种类型的节点。 我怎么能理解这个diffgram文件,我可以生成一个HTML

您可以在XmlDiffView类中使用您的diffgram。 但对我来说,它并不完美。 它突出了差异,但也表明我删除了一些节点并添加了新的。

 XmlDiffView dv = new XmlDiffView(); //Load the original file again and the diff file. XmlTextReader orig = new XmlTextReader("F:\\XML_1.xml"); XmlTextReader diffGram = new XmlTextReader("F:\\diff.xml"); dv.Load(orig, diffGram); //Wrap the HTML file with necessary html and //body tags and prepare it before passing it to the GetHtml method. string tempFile = "F:\\diff" +r.Next() + ".htm"; StreamWriter sw1 = new StreamWriter(tempFile); sw1.Write(""); //Write Legend. sw1.Write(""); dv.GetHtml(sw1); sw1.Write("
Legend: added  removed  changed  " + "moved from" + "  moved to" + "  " + "ignored
"); sw1.Close(); dv = null; orig.Close(); diffGram.Close();

我使用你的xml文件运行它,它们是相同的。 当我将值CommandString从ABC修改为ABCD时,我获得了高度更改的值。