NAME

XML::Compare - Test if two XML documents semantically the same

SYNOPSIS

use XML::Compare tests => 2;

my $xml1 = "<foo xmlns="urn:message"><bar baz="buzz">text</bar></foo>";
my $xml2 = "<f:foo xmlns:f="urn:message"><f:bar baz="buzz">text</f:bar></f:foo>";

eval { XML::Compare::same($xml1, $xml2); };
if ( $@ ) {
    print "same\n";
}
else {
    print "different: $@\n";
}

DESCRIPTION

This module allows you to test if two XML documents are semantically the same. This also holds true if different prefixes are being used for the xmlns, or if there is a default xmlns in place.

This modules ignores XML Comments.

SUBROUTINES

same($xml1, $xml2)

Returns true if the two xml strings are semantically the same.

If they are not the same, it throws an exception with a description in $@ as to why they aren't.

is_same($xml1, $xml2)

Returns true if the two xml strings are semantically the same.

Returns false otherwise. No diagnostic information is available.

is_different($xml1, $xml2)

Returns true if the two xml strings are semantically different. No diagnostic information is available.

Returns false otherwise.

EXPORTS

Nothing.

SEE ALSO

XML::LibXML

AUTHOR

Andrew Chilton, <andychilton@gmail.com<gt>, <andy@catalyst dot net dot nz<gt>

http://www.chilts.org/blog/

COPYRIGHT & LICENSE

This software development is sponsored and directed by New Zealand Registry Services, http://www.nzrs.net.nz/

The work is being carried out by Catalyst IT, http://www.catalyst.net.nz/

Copyright (c) 2009, NZ Registry Services. All Rights Reserved. This software may be used under the terms of the Artistic License 2.0. Note that this license is compatible with both the GNU GPL and Artistic licenses. A copy of this license is supplied with the distribution in the file COPYING.txt.