Edward Kawas

NAME

XML::SemanticCompare - compare 2 XML trees semantically

SYNOPSIS

        use XML::SemanticCompare;
        my $x = XML::SemanticCompare->new;

        # compare 2 different files
        my $isSame = $x->compare($control_xml, $test_xml);
        # are they the same
        print "XML matches!\n"
          if $isSame;
        print "XML files are semantically different!\n"
          unless $isSame;

        # get the diffs and print them out
    my $diffs_arrayref = $x->diff( $control_xml, $test_xml );
    print "Diff: $_\n" foreach (@$diffs_arrayref);

        # test xpath statement against XML
        my $success = $x->test_xpath($xpath, $test_xml);
        print "xpath success!\n" if $success;

DESCRIPTION

This module is used for semantically comparing XML documents.

AUTHORS

Edward Kawas (edward.kawas+xml-semantic-compare@gmail.com)

SUBROUTINES

new

constructs a new XML::SemanticCompare reference. parameters (all optional) include:

trim - if set to a true value, then all whitespace is trimmed when comparing text. [defaults to 1]
use_attr - if set to a true value, then all attributes and elements are compared. [defaults to 1]

trim

getter/setter - use to get/set whether or not you would like whitespace trimmed before comparing text. Setting this to a true value (e.g. 1) causes text to be trimmed before being compared. Setting to undef leaves text as is.

use_attr

getter/setter - use to get/set whether or not you would like compare attributes. Setting this to a true value (e.g. 1) will allow you to compare attributes and elements. Setting to undef causes SemanticCompare to ignore attributes.

compare

subroutine that determines whether or not the passed in text XML is semantically similar to the passed in control XML.

parameters - a scalar string of control XML (or a file location) and a scalar string of test XML (or a file location) to compare against each other.

a true value is returned if both XML docs are semantically similar, otherwise undef is returned.

test_xpath

subroutine that applies an XPATH expression to the passed in XML.

parameters - a scalar string representing an XPATH expression and a scalar string of XML (or a file location) to test it against.

a true value is returned if the xpath statement matches 1 or more nodes in the XML, otherwise undef is returned.

diff

subroutine that retrieves any differences found when comparing control XML and the test XML passed into this sub.

parameters - a scalar string of control XML (or a file location) and a scalar string of test XML (or a file location) to compare against each other.

an array ref of strings representing the differences found between xml docs is returned. The strings look like XPATH statements but are not actual XPATH statements.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 468:

=cut found outside a pod block. Skipping to next block.