File1 123 Platypus Lane Burgopolis FL 12345 File2 123 Platypus Lane Burgopolis FL 678 File3 123 Platypus Lane Burgopolis FL 910 #### #!/usr/bin/perl use XML::XPath; my $file = 'file.xml'; my $xp = XML::XPath->new(filename=>$file); my $nodeset = $xp->find('//name'); my @names; # Where we'll put our results if (my @nodelist = $nodeset->get_nodelist) { @names = map($_->string_value, @nodelist); # Now sort and prepare for output @names = sort(@names); local $" = "\n"; print "I found these names:\n@names\n"; }