in reply to Re^5: XML::Simple for sequence in xsd
in thread XML::Simple for sequence in xsd
with:my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1);
Here's the (final) amended version of the script:my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1, NoSort + => 1);
Cheers,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> ';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: XML::Simple for sequence in xsd
by Anonymous Monk on Aug 23, 2007 at 15:10 UTC |