如何使用XmlDiffView GetHTML

时间:2016-10-21 14:54:49

标签: c# .net xml xmldiff

我们有两个xml文件,需要找到它的差异。为此,我们使用XMLDiff库。我们能够获得差异,但现在想要一个显示已修改节点的UI。所以使用了XmlDiffView类。代码如下

  XmlDiffView dv = new XmlDiffView();
        //Load the original file again and the diff file.
        XmlTextReader orig = new XmlTextReader(oldXML);
        XmlTextReader diffGram = new XmlTextReader(diffXML);
        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 = @"C:\Users\ABC\Desktop\diffView.html";
        StreamWriter sw1 = new StreamWriter(tempFile);
        sw1.Write("<html><body><table width='100%'>");


        dv.GetHtml(sw1);
        sw1.Write("</table></body></html>");
        sw1.Close();
        dv = null;
        orig.Close();
        diffGram.Close();

从上面的代码中,dv.GetHtml(sw1);这个语句给出了html文件,它显示了所有已修改和未修改的节点,但是我们只需要获取已修改的节点信息。

我们怎样才能获得修改后的模式信息? 任何暗示,参考都会有很大的帮助。 谢谢!

0 个答案:

没有答案