in reply to Re^5: XML::Simple for sequence in xsd
in thread XML::Simple for sequence in xsd

I couldn't find an easy way to deal with that

But moritz had found the solution to that in an earlier post in this thread (moritz++). It's just a matter of replacing:
my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1);
with:
my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1, NoSort + => 1);
Here's the (final) amended version of the script:
use strict; use XML::Simple; use Data::Dumper; use Tie::IxHash; my $Request_data = {}; tie my %NewOrder_data , 'Tie::IxHash'; tie my %r, 'Tie::IxHash'; my $request_xml = \%r; %NewOrder_data = ( 'IndustryType' => ['EC'], 'CurrencyCode' => ['840'], 'CurrencyExponent1' => ['1'], 'CurrencyExponent2' => ['2'], ); my @keys = keys %NewOrder_data; print "\n@keys\n"; my $xmlDS = { Request => [ { NewOrder => [ \%NewOrder_data, ], } ], }; $request_xml = eval { my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1, NoSort + => 1); $xs->XMLout($xmlDS); }; print STDERR "\n\nxml :- >\n" . Dumper($request_xml); __END__ Outputs: IndustryType CurrencyCode CurrencyExponent1 CurrencyExponent2 xml :- > $VAR1 = '<Request> <NewOrder> <IndustryType>EC</IndustryType> <CurrencyCode>840</CurrencyCode> <CurrencyExponent1>1</CurrencyExponent1> <CurrencyExponent2>2</CurrencyExponent2> </NewOrder> </Request> ';
Cheers,
Rob

Replies are listed 'Best First'.
Re^7: XML::Simple for sequence in xsd
by Anonymous Monk on Aug 23, 2007 at 15:10 UTC
    Hi Rob, it working greatly!!!!!!! Now I can move to build the gateway request easily. Thanks and Cheers.... Sham.