Hi Rob,
Tying up the hash is done fantastically with the Tie::IxHash module.
But when I pass the this tied hash to the XML::Simple it no more follow the
tie for the hash.
I am trying to get the XML nodes in the sequence which I am following to create
the hash elements.
Following is the sample code and the output which I am trying to get correct result.
If I am missing somewhere please suggest.
use strict;
use XML::Simple;
use Data::Dumper;
use Tie::IxHash;
my $Request_data = {};
tie my %NewOrder_data , 'Tie::IxHash';
%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,
}
],
}
],
};
my $request_xml = eval {
my $xs = new XML::Simple(keeproot => 1, SuppressEmpty => 1);
$xs->XMLout($xmlDS);
};
print STDERR "\n\nxml :- >\n" . Dumper($request_xml);
__END__
OUTPUT :------->
IndustryType CurrencyCode CurrencyExponent1 CurrencyExponent2
xml :- >
<Request>
<NewOrder1>
<CurrencyCode>840</CurrencyCode>
<CurrencyExponent2>2</CurrencyExponent2>
<IndustryType>EC</IndustryType>
<CurrencyExponent1>1</CurrencyExponent1>
</NewOrder1>
</Request>
Thanks,
Sham |