Romanuse strict; use warnings; use XML::LibXML; my $doc = XML::LibXML->new->parse_file('abc.xml'); my @class_elems = $doc->findnodes('/*/class'); my @sorted_class_elems = sort { $a->findvalue('strength') <=> $b->findvalue('strength') } @class_elems; for my $node (@class_elems) { $node->replaceNode( shift(@sorted_class_elems)->cloneNode(1) ); } open( my $fh, '>', 'xyz.xml' ); $fh->print( $doc->toString(1) );
In reply to Re: Sort n Create XML
by roman
in thread Sort n Create XML
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |