Prints:$root->first_child->sort_children_on_att("type"); sort_my_kids($root); $twig->print; #---------- sub sort_my_kids{ my $me = shift; $me->sort_children_on_value; foreach my $kid($me->children){ sort_my_kids($kid); # Recursive } }
<enhancement> <descriptorgroup> <descriptors controlled="y" type="DRG"> <mainterm weight="a">aspirin</mainterm> <mainterm>panadol</mainterm> <mainterm>xenon</mainterm> <mainterm weight="a">zorro</mainterm> </descriptors> <descriptors controlled="y" type="MED"> <descriptor> <mainterm>disease</mainterm> <mainterm>pestilence</mainterm> <mainterm weight="a">plague</mainterm> </descriptor> </descriptors> </descriptorgroup> </enhancement>
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: twig inbuilt methods to sort whole xml tree
by NetWallah
in thread twig inbuilt methods to sort whole xml tree
by bharathinc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |