in reply to XML::LibXML out of memory
Based on the sample input posted here, this produces the same output as the original code:
use warnings; use strict; use XML::Twig; my $file = 'input.xml'; XML::Twig->new( twig_roots => { '/martif/text/body/termEntry/*' => sub { my ($t, $elt) = @_; for my $e ($elt->get_xpath('./tig/term')) { print $elt->{att}->{'xml:lang'}, ": ", $e->text_only, +"\n"; } $t->purge; }, }, )->parsefile($file);
You could add use open qw/:std :utf8/; at the top to get the output printed to STDOUT in UTF-8 as well.
|
|---|