Test::XML::Compare - Test if two XML documents semantically the same
use Test::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>"; my $xml3 = "<foo><bar baz="buzz">text</bar></foo>"; # These will pass is_xml_same $xml1, $xml2; # These will fail is_xml_same $xml1, $xml3; is_xml_same $xml2, $xml3; # however, you can also check for failures, so these now succeed is_xml_different $xml1, $xml3; is_xml_different $xml2, $xml3; # ... and this fails is_xml_different $xml1, $xml2;
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.
It uses XML::Compare to do all of it's checking.
Test passes if the XML string in $xml1 is semantically the same as the XML string in $xml2. Optionally name the test with $name.
$xml1
$xml2
$name
Test passes if the XML string in $xml1 is semantically different to the XML string in $xml2. Optionally name the test with $name.
Everything in "SUBROUTINES" by default, as expected.
Test::Builder
XML::LibXML
XML::Compare
Andrew Chilton, <andychilton@gmail.com<gt>, <andy@catalyst dot net dot nz<gt>
http://www.chilts.org/blog/
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.
To install XML::Compare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Compare
CPAN shell
perl -MCPAN -e shell install XML::Compare
For more information on module installation, please visit the detailed CPAN module installation guide.