perl xml check for element closure

I'm interested in writing a perl script that checks an xml document for
proper element closure only. There is no dtd associated, so this is
really the only type validation I could think of... Is there an easy
way to do this via perl? All I'm looking for is a simple 0 or 1 return
code.

Regards,

-Inet
inetquestion [ So, 19 November 2006 03:26 ] [ ID #1541195 ]

Re: perl xml check for element closure

I just found the code below which appears to be exactly what I was
looking for... As soon as I get back to my home pc I'll give it a
shot.

-Inet

----------------






use XML::Parser;

my $xmlfile = shift [at] ARGV; # the file to parse

# initialize parser object and parse the string
my $parser = XML::Parser->new( ErrorContext => 2 );
eval { $parser->parsefile( $xmlfile ); };

# report any error that stopped parsing, or announce success
if( $ [at] ) {
$ [at] =~ s/at \/.*?$//s; # remove module line number
print STDERR "\nERROR in '$xmlfile':\n$ [at] \n";
} else {
print STDERR "'$xmlfile' is well-formed\n";
}
inetquestion [ So, 19 November 2006 03:41 ] [ ID #1541196 ]
Perl » comp.lang.perl.modules » perl xml check for element closure

Vorheriges Thema: Trouble installing from CPAN
Nächstes Thema: HTTP Header variables empty ( randomly ) with mod_perl