Search the web
Sign In
New User? Sign Up
xml-treepp · XML::TreePP Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Unable to stop TreePP from sorting hash in order.   Message List  
Reply | Forward Message #13 of 32 |
In the following code I'm creating an XML structure from a hash. The
problem is that the XML structure always comes out in alphabetically
order even when I set 'first_order'. Can someone suggeest a way to
get TreePP to print the XML structure in a user defined order instead
of alphabetically order?

use strict ;
use XML::TreePP;


my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time()) ;
my $timestamp = sprintf( "%4d-%02d-%02dT%02d:%02d:%02d", ($year+1900),
($mon+1), $mday, $hour, $min, $sec ) ;

my $h = { Msg => { System => 'TH1'
, MessageType => '0'
, ProcessID => '100'
, TimeStamp => "$timestamp"
, Source => 'wazzup!'
}
} ;

my $tpp = XML::TreePP->new( ) ;
$tpp->set( indenting => 3 );
$tpp->set( first_out =>
[ 'System', 'MessageType', 'ProcessID', 'Timestamp', 'Source' ] ) ;
my $xml = $tpp->write($h) ;

print $xml ;





Thu Jul 19, 2007 10:02 pm

sajohn52
Offline Offline
Send Email Send Email

Forward
Message #13 of 32 |
Expand Messages Author Sort by Date

In the following code I'm creating an XML structure from a hash. The problem is that the XML structure always comes out in alphabetically order even when I set...
sajohn52
Offline Send Email
Jul 19, 2007
10:04 pm

... Before version 0.20, first_order option have sorted every elements on generating XML. After version 0.20, it now keeps the order given in a array for the...
Kawasaki Yusuke
kawa.kawa
Offline Send Email
Jul 22, 2007
11:06 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help