XML::Parser/XML::Parser::Expat 
Author Message
 XML::Parser/XML::Parser::Expat

These modules "die" when a parse error is encountered. Is there some way
to make them just print an informational message and go on? I'm
processing a lot of XML files at once, and I'd like to continue on to
the next file if the parsing of one fails.

Thanx,
Swaroop

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 XML::Parser/XML::Parser::Expat

Quote:

> These modules "die" when a parse error is encountered. Is there some way
> to make them just print an informational message and go on? I'm
> processing a lot of XML files at once, and I'd like to continue on to
> the next file if the parsing of one fails.

Wrap them in an eval, e.g.:

  use XML::Parser;
  # ...
  my $p = XML::Parser->new( Style => 'Objects' );

      my $o;
      eval { $o = $p->parsefile( $file ) };


      }
      else {
          # process $o;
      }
   }

--
Jeff



Wed, 18 Jun 1902 08:00:00 GMT  
 XML::Parser/XML::Parser::Expat

Quote:

> These modules "die" when a parse error is encountered. Is there some
> way to make them just print an informational message and go on? I'm
> processing a lot of XML files at once, and I'd like to continue on
> to the next file if the parsing of one fails.

eval() each file?

See you,
--

Departamento de Publica??es       Conectiva S.A.
Publishing Department             Conectiva Inc.



Wed, 18 Jun 1902 08:00:00 GMT  
 XML::Parser/XML::Parser::Expat

Quote:


>> These modules "die" when a parse error is encountered. Is there some
>> way to make them just print an informational message and go on? I'm
>> processing a lot of XML files at once, and I'd like to continue on
>> to the next file if the parsing of one fails.
> eval() each file?

Nope.  eval{} each file.  Remember that the string form of eval is a
totally different animal from the block form of eval.  The latter is
Perl's try/catch mechanism.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. XML-PARSER-2_30 expat compile expat.h missing

2. Expat XML:Parser install and Running ActivePerl and IndigoPerl

3. Expat and xml::parser on windows server.

4. XML-Parser and Expat

5. Perl, XML Parser and Expat

6. Newbie Question: XML::Parser & Expat build problems

7. expat: XML::Parser

8. expat XML parser

9. XML::Parser::Expat

10. Parsing XML (Not XML::Parser)

11. Problem on installing XML-Simple/XML-Parser on LynxOS

12. I want to stop XML::Parser from processing CDATA tags in my XML

 

 
Powered by phpBB® Forum Software