perl - XML::Twig and save order of attributes -
perl - XML::Twig and save order of attributes -
i editing xml files using xml::twig
below 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 code not save xml attributes in same order in edited file.
for illustration line input xml :
<device overwrite="true" string="true" block="false">
is replaced line in output xml :
<device block="false" string="true" overwrite="true">
how can save attributes in same order original file if compare 2 files revision system, see changes made?
are sure order block
, string
, overwrite
? bit surprising.
to reply question: seek installing tie::ixhash
, using keep_atts-order
alternative when create twig. should it.
i not sure why need though: order shouldn't matter (proper) xml processor. if need version control, have @ cvs
value pretty_print
option, designed play nice line-oriented tools.
xml perl xml-twig
Comments
Post a Comment