SYNOPSIS

  use Test::XML tests => 3;
  is_xml( '<foo />', '<foo></foo>' );   # PASS
  is_xml( '<foo />', '<bar />' );       # FAIL
  isnt_xml( '<foo />', '<bar />' );     # PASS
  is_well_formed_xml('<foo/>');               # PASS
  is_well_formed_xml('<foo>');                # FAIL

DESCRIPTION

This module contains generic \s-1XML\s0 testing tools. See below for a list of other modules with functions relating to specific \s-1XML\s0 modules.

FUNCTIONS

is_xml ( \s-1GOT\s0, \s-1EXPECTED\s0 [, \s-1TESTNAME\s0 ] )

This function compares \s-1GOT\s0 and \s-1EXPECTED\s0, both of which are strings of \s-1XML\s0. The comparison works semantically and will ignore differences in syntax which are meaningless in xml, such as different quote characters for attributes, order of attributes or empty tag styles. Returns true or false, depending upon test success.

isnt_xml( \s-1GOT\s0, \s-1MUST_NOT_BE\s0 [, \s-1TESTNAME\s0 ] )

This function is similiar to is_xml(), except that it will fail if \s-1GOT\s0 and \s-1MUST_NOT_BE\s0 are identical.

is_well_formed_xml( \s-1XML\s0 [, \s-1TESTNAME\s0 ] )

This function determines whether or not a given \s-1XML\s0 string is parseable as \s-1XML\s0.

is_good_xml ( \s-1XML\s0 [, \s-1TESTNAME\s0 ] )

This is an alias for is_well_formed_xml().

NOTES

There are several features of XML::SemanticDiff that may suprise you if you are not aware of them. In particular:

  • Leading and trailing whitespace is always stripped, even in elements with character content.

  • Whitespace inside character content is always stripped down to a single space.

  • In mixed content elements (ie: an element with both text and elements beneath it), all text is treated as a single value.

  • The order of elements is ignored.

RELATED TO Test::XML…

Test::XML::SAX, Test::XML::Twig.

Test::More, XML::SemanticDiff.

AUTHOR

Dominic Mitchell, <cpan2 (at) semantico.com>

COPYRIGHT AND LICENSE

Copyright 2002 by semantico

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.