Test::XML(3pm)

Test::XML3pm

Compare xml in perl tests

Usage

  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

Overview

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

Functions

is_xml ( GOT, EXPECTED [, TESTNAME ] )

This function compares GOT and EXPECTED, both of which are strings of XML. 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( GOT, MUST_NOT_BE [, TESTNAME ] )

This function is similar to is_xml(), except that it will fail if GOT and MUST_NOT_BE are identical.

is_well_formed_xml( XML [, TESTNAME ] )

This function determines whether or not a given XML string is parseable as XML.

is_good_xml ( XML [, TESTNAME ] )

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.

Releases

7 releases since Debian 7 (Wheezy); the text changed 4 times.

  1. 7
  2. 8
  3. 9–10
  4. 11
  5. 12–13

Author

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

From libtest-xml-perl 0.08-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.