Compare two XMLs

I am pretty new to comparing the xmls in c#. Can somebody suggest me a easy and performant way to do the same. Below is my requirement.

Source XML file:

<a>
 <b>hello</b>
<c>
<d>
 <e>abcd</e>
</d>
</c>
<f>image1</f>
</a>

Destination XML file:

<a>
 <b1>hello</b1>
<c>
<d>
 <e>thguh</e>
</d>
</c>
<f>image2</f>
</a>

In the xml files as for tag, i don't want to see it as difference as it is intended. Hence i want to filter out such differences and see if there are any other differences like node values and node names. Comparing node values and filtering the image value changes and finally telling the differences is my priority.

Answers


you can use XMLDiff to compare the xml files XML Differance and compare

   XmlDiff xmldiff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder |
                            XmlDiffOptions.IgnoreNamespaces |
                            XmlDiffOptions.IgnorePrefixes);

then compare

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

Need Your Help

Unable to load assembly in VS, but works in MSBuild

visual-studio msbuild t4 gac

I'm trying to load an assembly in a T4 template. While it works perfectly fine when executing the transforms from MSBuild, the T4 engine reports that it cannot find the assembly when running from V...

Load HashMap values from Xml file

java xml java-ee

How to load a hashmap from your XML and inject it into a real object in JAVA

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.