Here goes my next question (I apologize for being such a nag). After
extensive reading on XML processing technologies I figured for my
application of XML files with hundreds of same-level branches XML::Twig is
the answer. Note that I do not do *any* XML output - I am just and only
processing interesting data from premade XML files, thus I am interested in
the simplest and least resource expensive approach. I got the thing to work
and all, indeed the memory footprint is a little smaller than with
XML::Simple (not by much though, I still waste xml_size*4 memory while
processing). The bigger question is why the code:

my $objinfo_parser = XML::Twig->new (   
                        twig_handlers => { 'Product' => \&product_handler },
                        twig_roots => { 'Products/Product' => 1 }
                  );

$objinfo_parser->parseurl ('http://www.3btech.net/3btech/objinfo.xml');


sub product_handler {

    my ($twig, $child) = @_;

    print ' * ';

    $twig->purge;
}


Produces all * after everything is processed, instead of printing them one 
by one once every product tag closes? From what I understood it crawls 
through an XML linearly (that's the only way anyway), and once it encounters 
an opening tag for anything that matches twig_roots it starts recording, 
once it sees the closing tag it has a complete sub-branch (twig), gives it 
to the corresponding handler, the handler purges it at the end of the sub 
and everything starts over again... However this is obviously not happening. 

Thanks for the input

Peter

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to