#!/usr/bin/perl -w use XML::DOM; my $parser = new XML::DOM::Parser; my $doc = $parser->parsefile ("url_config.xml"); my $nodes = $doc->getElementsByTagName( "url" ); my $entries = $nodes->getLength; my @id_array; # insert all the id`s in a array: for (my $i = 0; $i < $entries; $i++) { my $node = $nodes->item ($i); my $href = $node->getAttributeNode ("id"); print $href->getValue . "\n"; push(@id_array, $href->getValue); } # last id: my $last_id = pop(@id_array); print $last_id; print "\n"; print "total no. of records::" . $entries . "\n";