Ben Siders wrote:

> Are there any CPAN modules that can analyze XML or HTML and report any
> cases of unclosed tags?  For example:
> 
> <note>
>     <subject>Hello, world</subject>
>     <author>Me</author>
>     <content>Hey, is thing <bold>thing on?</content>
> </note>
> 
> In the above, I'd like to find a method of detecting that the bold tag
> is missing a </bold> closer.

try:

#!/usr/bin/perl -w
use strict;
use XML::Parser;

open(XML,'foo.xml') || die $!;

my $xml = XML::Parser->new;

eval{
        $xml->parse(*XML);
};

print "ERROR: $@" if($@);

close(XML);

__END__

if any tag in foo.xml is mismatched(missing, typo, etc), you will get 
somethinglike:

ERROR:
mismatched tag at line 10, column 2, byte 165 at 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser.pm line 
185

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to