XML::Twig and save order of attributes
问题 I am editing some XML files using XML::Twig below are the code : my $twig = XML::Twig->new( pretty_print => 'indented', twig_handlers => { Vendor => sub { $_->set_att( 'ID' => $_->{'att'}->{'att1'} ); $_->set_att( 'ID' => $_->{'att'}->{'att2'} ); $_->set_att( 'ID' => $_->{'att'}->{'att3'} ); $_->set_att( 'ID' => $_->{'att'}->{'att4'} ); }, }, ); $twig->parsefile('myfile'); $twig->flush; The problem is that this code does not save the xml attributes in the same order in the edited file. for