use strict; use warnings; use XML::Twig; my $xmlStr = < XML my $twig = new XML::Twig(twig_handlers => {'*' => \&testcase}); $twig->parse($xmlStr); sub testcase { my ($twig, $testcase) = @_; my $tag = $testcase->tag(); return 1 if $tag !~ /^testcase\d+$/; print "$tag\n"; for my $step ($testcase->children()) { my $tag = $step->tag(); my %attrs = %{$step->atts()}; print "Command: $attrs{'command'}("; print join ', ', map {$attrs{$_}} grep {/^param/} sort keys %attrs; print ")\n"; } print "\n"; }