in reply to XML::Twig ignore_elts
The ignore_elt parameter doesn't do what you think it does. It tells XML::Twig to pretend that element doesn't even exist. So what you want is to remove that, and then inside the title function, check where you're at. One way is this:
This means XML::Twig will read and parse the title/title/title elements, but when we get there, we check how many levels of title's there are above us, and if that is 2 (that means we're the 3rd), then we don't set_gi.my $twig = XML::Twig->new( twig_handlers => { $sel => \&title}, pretty_print => 'indented' ); # ... sub title { my ($twig, $tit) = @_; $tit->set_gi('tit') unless $tit->level('title') == 2; }
Good luck.
|
|---|