*[@att='type'] => \&changeTagAttrOrderHandler; #### $rootElt->set_atts( { $att1 => $att1Val, $att2 => $att2Val, $att3 => $att3Val}); #### use warnings; use strict; use XML::Twig; use Tie::IxHash; my $tw = XML::Twig->new("keep_atts_order", 1); my %atts; tie %atts, Tie::IxHash::; # <----- %atts = ("year", 2010, "month", 3, "day", 5); $tw->set_root(XML::Twig::Elt->new("date", \%atts)); $tw->flush; print "\n"; __END__ #### use warnings; use strict; use XML::Twig; my $tw = XML::Twig->new("keep_atts_order", 1); $tw->set_root(my $de = XML::Twig::Elt->new("date")); $de->set_att("year", 2010, "month", 3, "day", 5); $tw->flush; print "\n"; __END__