[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-xml
Subject:    Re: Interrupting/Stopping Parsing
From:       Eric Bohlman <ebohlman () earthlink ! net>
Date:       2001-03-16 3:42:22
[Download RAW message or body]

3/9/01 7:06:25 PM, Sami Itkonen <si@iki.fi> wrote:

>On Fri, 09 Mar 2001, Paul Dlug wrote:
>
>> Using XML::Parser is there a way to end parsing once the desired 
information has been extracted? I'm looking for a way to eliminate the need to 
parse the entire XML file (which can get very large) to only extract a few 
pieces of information. 
>> 
>
>You could try using non-blocking expat (XML::Parser::ExpatNB) - then you
>can feed it the file, bit by bit. You can then stop the operation whenever
>you feel like it.

There are several modules that use this technique: you can take a look at 
their code to see how they do it, or even find that the modules themselves 
will meet your requirement.  There's Robert Hanson's XML::RAX and my 
XML::TokeParser, XML::TiePYX (and XML::Records, though the next version of it 
will be a subclass of XML::TokeParser).  One thing all of the have in common 
is that they provide a "pull" interface similar to the familiar 'while (<IN>)' 
loop (i.e. the program asks the parser for the next record, token, etc.) 
rather than a "push" interface where the parser takes control and calls your 
callback subs.


_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic