use strict; use warnings; use XML::Twig; my $xml = q{}; my $t = XML::Twig->new( twig_handlers => { timeLimit => sub { my $atts = $_->atts; foreach (keys %$atts) { /^(?:start|end)Time$/ && do {print "$_ => $atts->{$_}\n"; next;}; } }, }, ); $t->parse($xml);