The XML you posted was incomplete - I had to trim and balance it to make it work, but it works ok after that, producing:
?xml version="1.0" encoding="UTF-8"?> <bibdataset xmlns="http://www.elsevier.com/xml/ani/ani" xmlns:ait="htt +p://www.elsevier.com/xml/ani/ait" xmlns:ce="http://www.elsevier.com/x +ml/ani/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation="http://www.elsevier.com/xml/ani/ani http://www.el +sevier.com/xml/ani/ani512.xsd"> <item> <ait:process-info> <ait:date-delivered day="04" month="03" year="2010"></ait:date-d +elivered> <ait:date-sort day="1" month="1" year="2000"></ait:date-sort> <ait:status stage="S300" state="new" type="core"></ait:status> </ait:process-info> <bibrecord> <head> <abstracts> <abstract original="y"> <ce:para>Controversy exists concerning the correct surgica +l management .....</ce:para> </abstract> </abstracts> <author-group> <affiliation country="usa"> <address-part>3000 W Cypress Creek Rd</address-part> <city-group>Fort Lauderdale, FL 33309</city-group> <organization>Department of Colorectal Surgery, Cleveland +Clinic Florida</organization> </affiliation> ....
The reason you and I are getting the
Use of uninitialized value in string comparison (cmp) at /usr/share/pe +rl5/XML/Twig.pm line 8567. Use of uninitialized value in string comparison (cmp) at /usr/share/pe +rl5/XML/Twig.pm line 8567.
is because the statement
        $root->first_child->sort_children_on_att("type")
requires the first child ("item", in your data) to contain the attribute "type", but it does not.

You need to decide what attribute name you want the xml order to be based on, and pass the right parameter.

     Theory is when you know something, but it doesn't work.
    Practice is when something works, but you don't know why it works.
    Programmers combine Theory and Practice: Nothing works and they don't know why.         -Anonymous


In reply to Re^6: twig inbuilt methods to sort whole xml tree by NetWallah
in thread twig inbuilt methods to sort whole xml tree by bharathinc

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.