my $twig = XML::Twig->new(keep_encoding => 1, twig_handlers => {'lemma' => \&ProcessLemma}); sub ProcessLemma { my ($XmlTwig, $XmlLemma) = @_; # extract information here... $XmlLemma->purge; return 1; }