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