[Israel.pm] XML processing problem
Shlomo Yona
shlomo at cs.haifa.ac.il
Thu Jun 10 03:13:05 PDT 2004
Hello,
Please consider the following code snippet:
use XML::Twig;
my $twig=XML::Twig->new(
twig_roots => {
item => \&handle_item
},
twig_print_outside_roots => 0,
keep_encoding =>1,
);
$twig->parsefile( 'myfile.xml' );
$twig->flush; # flush the end of the document
sub handle_item {
my( $twig, $item)= @_;
# do something with $item
}
I was surprised to see that this code prints *some* of my
XML file, although
twig_print_outside_roots => 0
Moreover, it seems that all the file is being processed and
only then output (the output I don't even want) is being
printed to the standard output. This is although this method
should be processing the XML one 'item' at a time without
building the twig of the whole xml file.
Any ideas what's going on?
--
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/
More information about the Perl
mailing list