use strict; use XML::Simple; my $org = <<'XML'; XML # parse the input string my $root = XMLin ($org, KeepRoot => 1, ); # Insert the element $root->{FILER}{LOCATION}{name} = '1stFloor'; # Dump the result print XMLout ($root, RootName => undef);