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

In reply to Re^6: XML::Simple for sequence in xsd by syphilis
in thread XML::Simple for sequence in xsd by Sham

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.