#!/usr/bin/perl -w use strict; use XML::Twig; my $t= XML::Twig->new( twig_roots => { CasualAdvertiser => 1 }) # so we only load CasualAdvertiser elements ->parsefile( "bcc.xml"); foreach my $ad ( sort { $a->field( 'Price') <=> $b->field( 'Price') } $t->root->children( 'CasualAdvertiser')) { printf "price: %8.2d - %-30s - %6d: ID%s\n", $ad->field( 'Price'), $ad->field( 'Make') . " " . $ad->field( 'Family'), $ad->field( 'Kilometres'), $ad->field( 'AdvertisementID'), ; } exit;