my $t = XML::Twig->new( twig_roots => {'nitf/body/body.head/hedline/hl1' => \&fix_hl1, 'nitf/body/body.head/hedline/hl2' => \&fix_hl2, _default_ => \&fixup, }, twig_print_outside_roots => 1, keep_encoding => 1, ); #### sub fixup { my ($tree, $elem) = @_; my $tag = $elem->tag; plog("in fixup: tag = $tag"); if ($fixup_tag{$tag}) { my $t = $elem->text; conv_chars(\$t); $elem->set_text($t); } $elem->print; }