use XML::Simple; use Data::Dumper; use strict; use warnings; my $data = do {local $/;}; my $xml = new XML::Simple(keeproot => 1);# this is what you want my $tree = $xml->XMLin($data); print Dumper($tree); __DATA__