I have a requirement to compare two XML documents and report differences. String comparison is not sufficient as I want to be able to say that:
<Foo/>
is the same as
<Foo></Foo>
Anyone used a library they would recommend?
I have a requirement to compare two XML documents and report differences. String comparison is not sufficient as I want to be able to say that:
<Foo/>
is the same as
<Foo></Foo>
Anyone used a library they would recommend?
There's the cunningly named xmldiff which I've used before with success.
XMLUnit also works well. It's primarily for use in unit tests (alongside JUnit).
or try diffxml:
The standard Unix tools diff and patch are used to find the differences between text files and to apply the differences. These tools operate on a line by line basis using well-studied methods for computing the longest common subsequence (LCS).
Using these tools on hierarchically structured data (XML etc) leads to sub-optimal results, as they are incapable of recognizing the tree-based structure of these files.
This project aims to provide Open Source XML diff and patch utilities which operate on the hierarchical structure of XML documents.
What I always do is format both sides of the XML (xmllint -format) and diff the results.