The attributes sorted by ascending order by default even if i am using keep_atts_order. How can i keep the required attributes in the same order which i have gievn in the set_atts command.
I need the order like bid, aid, att, pgnbr etc.,
use XML::Twig; my $xmlfile = 'check.xml'; my $twig=XML::Twig->new( twig_handlers=>{ keep_atts_order=>1, color=>\&content_handler}, pretty_print => 'indented', ); $twig->parse(\*DATA); sub content_handler { my ($twig, $color)=@_; $color->del_atts; $color->set_atts({bid=>$bidvar, aid=>$aidvar, att=>'', pgnbr=>$pgnbrva +r, pgsect=>$pgsectvar, spp=>'', spf=>$spfval, top=>$topvar, left=>$le +ftvar, height=>$heightvar, bh=>$bhvar, width=>$widthvar, bw=>$bwvar, +colums=>$columsvar, gutter=>$guttervar, ts=>$tsvar, ls=>$lsvar, bs=>$ +bsvar, rs=>$rsvar, t=>$tvar, l=>$lvar, b=>$bvar, r=>$rvar, tit=>$titv +ar, til=>$tilvar, tib=>$tibvar, tir=>$tirvar, color=>$colorvar, cn=>$ +cnvar, framewidth=>$framewidthvar, framecolor=>$framecolorvar, fcn=>$ +fcnvar, grp=>$grpvar}); } $twig->print; __DATA__ <?xml version="1.0"?> <document> <root> <box type="text" cont="text" textflowid="rc_u5035" frameColorID="ua +5"/> </root> <content type="text" Self="rc_u5035" id="rc_u5035"/> <header>h3</header> <meta> <color type="colr" clmd="prss" clsp="CMYK" clvl="4_D_0_D_15_D_50_D_0 +" ovrd="norm" atcs="nasp" atvl="0" pnam="Color 04-15M/50Y" edbl="t" r +mbl="t" pvis="t" swID="1f01" Self="uce"/> <color type="colr" clmd="prss" clsp="CMYK" clvl="4_D_0_D_10_D_40_D_0 +" ovrd="norm" atcs="nasp" atvl="0" pnam="Color 05-10M/40Y" edbl="t" r +mbl="t" pvis="t" swID="1f01" Self="ua5"/> </meta> </document>
CURRENT OUTPUT
<?xml version="1.0"?> <document> <root> <box cont="text" frameColorID="ua5" textflowid="rc_u5035" type="te +xt"/> </root> <content Self="rc_u5035" id="rc_u5035" type="text"/> <header>h3</header> <meta> <color aid="" att="" b="" bh="" bid="" bs="" bw="" cn="" color="" +colums="" fcn="" framecolor="" framewidth="" grp="" gutter="" height= +"" l="" left="" ls="" pgnbr="" pgsect="" r="" rs="" spf="" spp="" t=" +" tib="" til="" tir="" tit="" top="" ts="" width=""/> <color aid="" att="" b="" bh="" bid="" bs="" bw="" cn="" color="" +colums="" fcn="" framecolor="" framewidth="" grp="" gutter="" height= +"" l="" left="" ls="" pgnbr="" pgsect="" r="" rs="" spf="" spp="" t=" +" tib="" til="" tir="" tit="" top="" ts="" width=""/> </meta> </document>

In reply to xml::twig attributes by Selvakumar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.