SRU::Utils::XMLTest - XML testing utility functions


SRU documentation Contained in the SRU distribution.

Index


Code Index:

NAME

Top

SRU::Utils::XMLTest - XML testing utility functions

SYNOPSIS

Top

    use SRU::Utils::XMLText;
    ok( wellFormedXML($xml), '$xml is well formed' );

DESCRIPTION

Top

This is a set of utility functions for use with testing XML data.

METHODS

Top

wellFormedXML( $xml )

Checks if $xml is welformed.


SRU documentation Contained in the SRU distribution.

package SRU::Utils::XMLTest;

use strict;
use warnings;
use XML::LibXML;
use base qw( Exporter );

our @EXPORT = qw( wellFormedXML );

sub wellFormedXML {
    my $xml_string = shift;
    eval {  
        my $parser = XML::LibXML->new;
        $parser->parse_string($xml_string);
    };
    return $@ ? 0 : 1;
}

1;