Here is a solution using
XML::Twig. Please feel free to improve on it as I'm new to XML::Twig ...
use XML::Twig;
my $twig= new XML::Twig(
start_tag_handlers => { 'level' => \&start_level },
twig_handlers => { 'level' => \&end_level },
);
$twig->parsefile($file);
my @levels;
sub start_level {
push @levels, $_[1]->{att}{label};
print join ('.', @levels), "\n" if @levels == 3
}
sub end_level {
pop @levels;
}
-- Hofmator
Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.