use strict; use warnings; use XML::Twig; my $xfile = < Jane Doe42 John Doe43 Foo Bar43 EOF my $t= new XML::Twig(); $t->parse($xfile); my $people = $t->root(); my @persons = $people->children('person'); for (@persons) { my $name = $_->first_child('name')->text(); my $age = $_->first_child('age' )->text(); if ($age == 43) { print "$name is $age\n" } } __END__ John Doe is 43 Foo Bar is 43