my $xp=XML::XPath->new(filename=>$file); my $hash; my $id=$xp->find('//Associationid'); my $phone->find('//OfficePhone'); ... ... if ($id->get_nodelist){ $hash{$id}{$phone}{$fax}{$county}{$zip}; }