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 ;