in reply to Re^2: Trapping XML error using Perl
in thread Trapping XML error using Perl

I'm afraid that you can't do that with XML::Parse because it dies on malformed XML.

On the other hand try and see XML::SAX and XML::SAX::Exception. I think they can help you

Careful with that hash Eugene.

Replies are listed 'Best First'.
Re^4: Trapping XML error using Perl
by Anonymous Monk on Jun 14, 2008 at 07:56 UTC
    You're forgetting eval {}
    #!/usr/bin/perl -- use strict; use warnings; use XML::Parser; my $p1 = new XML::Parser(Style => 'Debug'); eval { $p1->parse('error NOW> <foo id="me">Hello World</foo>'); }; warn "CAUGHTS ANS ERRORS BOSSS: $@\n" if $@; undef $p1; __END__ CAUGHTS ANS ERRORS BOSSS: syntax error at line 1, column 0, byte 0 at ...