tags:

views:

312

answers:

3

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?

+1  A: 

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).

Brian Agnew
I must be not looking in the right places, but i can't find any files for xmldiff.
Stroboskop
It's some time since I used it. I'm wondering if I did a direct CVS checkout
Brian Agnew
Going with XMLUnit, which I know vaguely
Paul McKenzie
A: 

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.

pageman
The website says " The current version is 0.95 Beta. Please note that this is an beta release; it is not yet production quality." Which makes it a bit difficult to justify in the corporate world.
Paul McKenzie
A: 

What I always do is format both sides of the XML (xmllint -format) and diff the results.

reinierpost
Which would flag `<FOO/>` as different fom `<FOO></FOO>`.
Paul McKenzie
Is this Java-based ?
Brian Agnew