#!perl use strict; use warnings; use XML::Twig; my $t= XML::Twig->new(pretty_print => 'indented', twig_handlers => { 'city/name'=>sub{ print $_[1]->text,"\n"; }, 'city/population'=>sub{ print "Pop: ",$_[1]->text,"\n"; }, } ); $t->parseurl('http://athome.myminicity.com/xml'); __OUTPUT__ AtHome Pop: 18998557