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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.