RVK
RVK

Reputation: 1045

Comparison of two XML files node by node in .NET

I want to compare two xml files node by node(to check if both contain the same nodes with the same attributes,etc) and highlight the differences in the two xml files and print the nodes which are missing in either of the xml files using .NET

Also I would like to know what are all the methods of comparing xml files other than using .NET

Could someone give me an insight into this?

Upvotes: 3

Views: 5177

Answers (2)

Alex
Alex

Reputation: 2382

if you know the structure of your xml, you can deserialize it into objects and compare that way, this will take care of things being out of order and nodes looking like <foo /> vs <foo></foo>.

otherwise, it's more difficult. check out this link: XmlDiff

Upvotes: 0

Teoman Soygul
Teoman Soygul

Reputation: 25742

Well rather than writing an algorithm manually, you can use an open-source library like this one: http://diffplex.codeplex.com/ It does a line by line comparison rather than node-by-node comparison but it will save you the hassle of implementing all the highlighting and visuals by hand.

Upvotes: 3

Related Questions