#!/usr/bin/perl -w use strict; use XML::Simple; use Data::Dumper; my $doc; open(FH, "inc.xml") || die "Can't open inc.xml"; sysread(FH, $doc, -s FH); close FH; my $xs = new XML::Simple; # can use forcearray and keeproot my $ref = $xs->XMLin("$doc"); # works print $ref->{incident}->{'GDOT-INC-260089'}->{location}->{county}->{content} . "\n"; # doesnt work print $ref->{'incident'}->[0];