我们有两个 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 文件,但我们只需要获取修改节点信息。
我们如何才能只获得修改后的模式信息?任何提示,参考都会有很大帮助。谢谢你!