in reply to Re^5: twig inbuilt methods to sort whole xml tree
in thread twig inbuilt methods to sort whole xml tree

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