use strict; use XML::Simple; my $xs = new XML::Simple; my $xml = $xs->XMLin("policies.xml", forcearray => 1, keyattr => ['policies']); my $policyproperties = { 'name' => "1", 'link_name' => "2", 'description' => "3", 'date' => "4" }; # Add to hash $xml->{'addedone'} = $policyproperties; print "Content-type: text/html\n\n"; # Sort hash #@{ $xml->{'policies'} } = sort { "\L$a->{name}" cmp "\L$b->{name}"} @{ $xml->{'policies'} }; use Data::Dumper; print Dumper($xml); $xs->XMLout($xml, outputfile => "policies1.xml", attrindent => 1); ####