my $file = 'file.xml'; my $twig = new XML::Twig; ## Get twig object $twig->parsefile($file); ## parse the file to build twig my $root = $twig->root; ## Get the root element of twig my @elements = $root->children; ## Get elements list of twig foreach my $e (sort @elements){ my $cpc = ($e->first_child('EstimatedCPC')->text)*100; print $cpc,"\n"; } #### $twig->parsefile( "file.xml"); # build the twig my $root= $twig->root; # get the root of the twig (stats) my @players= $root->children; # get the player list # sort it on the text of the field my @sorted= sort { $b->first_child( $field)->text <=> $a->first_child( $field)->text } @players; print ''; # print the XML declaration print ''; print ''; # then the root element start tag foreach my $player (@sorted) # the sorted list { $player->print; # print the xml content of the element print "\n"; } print "\n"; # close the document #### new Puma Pitch Shorts Pitch Shorts: Let your football team look like pros and play like pros with these lightweight shorts from PUMA. Highly functional materials draw sweat away from your skin and help keep you dry and comfortable during exercise. Get ready for dry with dryCELL. Bio-based wicking finish to keep you dry. 0.0434 2017-02-15 21:31:41 http://r.kelkoo.com/r/uk/11210623/100353523/90/90/http%3A%2F%2Fpumaecom.scene7.com%2Fis%2Fimage%2FPUMAECOM%2F702075_25_01_EEA%3F%24PUMA_GRID%24/d4qCltxt.0XARAbgLGRcGsAKxgSY3iHhaVcF_7bEuPg- http://ecs-uk.kelkoo.co.uk/ctl/go/offersearchGo?.ts=1487245527057&.sig=Ch1dMBKSr5hhrL8bNhlNkv_GMSg&catId=100353523&localCatId=100353523&comId=11210623&offerId=af94bdd18ff9ffbf66afb5 286dcb68fa&searchId=null&affiliationId=96951977&country=uk&wait=true&contextLevel=2&service=11 false Miscellaneous 20.0 3.95 23.95 0 1 false 4055261425365 Male|Mens Sports Football Pants & Shorts Puma 2571 Pitch Shorts GBP