I have a heap of unit tests that need to check XML outputs.
I have started out comparing strings but this isn't going to scale as formatting and superficial differences get in the way.
What is the easiest way in .NET to evaluate whether the generated XML is semantically the same as what the test expects?
Closed as duplicate of How would you compare two XML Documents?
Steps to compare contents of two files Open both the files in VS Code. From the left Explorer panel, right-click the first file and choose Select for Compare from the right-click menu. Then right-click the second file and choose Compare with Selected.
Microsoft offers its XML Diff tools/classes here. I haven't personally used it, but it sounds like it'll get you started:
"By using the XMLDiff class, the programmer is able to determine if the two files are in fact different based on the conditions that are important to their application"
It seems to cope with different ordering, spacing, namespace prefixes etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With