my $hash_ref = XMLin($XML, KeyAttr=>[] , ForceArray=>["device"]); print "The array\n"; print Dumper($hash_ref->{devices}->{device}); print "The first element\n"; print Dumper($hash_ref->{devices}->{device}[0]); print "The first element another way\n"; my @array=$hash_ref->{devices}->{device}; print Dumper($array[0]);