使用C#进行XML比较

编程入门 行业动态 更新时间:2024-10-24 06:35:01
本文介绍了使用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比较

本文发布于:2023-10-23 14:03:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!