本文介绍了使用C#进行XML比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用两个diff xml我想比较xml中的所有元素而不显式指定元素名称。请有人帮帮我。紧急。
解决方案请仔细阅读以下文章可能会有所帮助 deepumi.wordpress/2010/03/02/compare-xml -files-using-csharp-linq / [ ^ ]
考虑到您只想比较以了解xml是否相同 试一试 bool bReturn = false ; XmlDocument xDoc = new XmlDocument(); XmlDocument xDoc2 = new XmlDocument(); xDoc.Load( XML Doc 1的路径); xDoc2.Load( XML Doc 2的路径); for ( int i = 0 ; i < xDoc.DocumentElement.ChildNodes.Count; i ++) { if (xDoc.DocumentElement.ChildNodes.Item(i).InnerXml!= xDoc2.DocumentElement.ChildNodes.Item(i).InnerXml) { bReturn = 真; // Xml不相同 } }
Hi, am using two diff xml I want to compare all the elements in the xml without explicitly specifying element name. Please anyone help me. Its urgent.
解决方案 please go through the below article may be it helps deepumi.wordpress/2010/03/02/compare-xml-files-using-csharp-linq/[^]Considering that you just want to compare to know whether that the xml are same or not Try this out bool bReturn = false; XmlDocument xDoc = new XmlDocument(); XmlDocument xDoc2 = new XmlDocument(); xDoc.Load("Path of the XML Doc 1"); xDoc2.Load("Path of the XML Doc 2"); for (int i = 0 ;i < xDoc.DocumentElement.ChildNodes.Count ; i++) { if(xDoc.DocumentElement.ChildNodes.Item(i).InnerXml != xDoc2.DocumentElement.ChildNodes.Item(i).InnerXml) { bReturn = true; //Xml are not same } }更多推荐
使用C#进行XML比较
发布评论