use strict; use warnings; use XML::Twig; my $xfile = < Hyundai 20000 Jeep 10000 F1 text F2 text EOF my $t= new XML::Twig(); $t->parse($xfile); for my $car ($t->root()->first_child('unsold')->children('car')) { print $car->first_child('model' )->text(), "\n"; print $car->first_child('mileage')->text(), "\n"; } for my $fnote ($t->root()->first_child('footnotes')->children('footnote')) { print $fnote->text(), "\n"; print $fnote->att('id'), "\n"; } __END__ Hyundai 20000 Jeep 10000 F1 text F1 F2 text F2