Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I am looking for WPF application for below scenario-

Compare 2 or more XML files in WPF using tree or datagrid like controls
and differences can be highlighted using colors like red, green etc.

If anyone has any sample or link for this scenario please do share here.

Cheers
Posted
Updated 18-Mar-15 5:59am
v2

1 solution

Comparing XML files is a bad idea. The file can have identical data content and differ in formatting and other detail. You can compare two files byte by byte, but then no knowledge that the files are XML (or even text file) should not be used. For this purpose, use the class System.IO.BinaryReader.

If you need to compare data, the best thing to use is the class System.Xml.XmlReader. You just read all the XML in the while (reader.Read()) { /* ... */ } loop, as shown in the code sample on the MSDN documentation page:
https://msdn.microsoft.com/en-us/library/system.xml.xmlreader%28v=vs.110%29.aspx[^].

Only you need to use two readers for two files and compare readers data on each step. Experiment with that to quickly understand how it works; it will be faster than explanation of further detail.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900