I have a hash representing an XML structure, where a part of it basically looks like this (I've simplified it a bit):

... arr => { elem => [ { mod => 'mstring1', rp => 'rstring1', subarr => { subelem => [ {...}, {...}, ... ] } }, { mod => 'mstring2', rp => 'rstring2', subarr => { subelem => [ {...}, {...}, ... ] } }, } ...
This structure has been processed by XMLin, using the option forcearray => [ qw(arr subarr) ]. Currently, I'm writing out this structure without any options. XMLout produces the following structure on output:
... <arr> <elem mod="mstring1" rp="rstring1"> <subarr> <subelem>...</subelem> <subelem>...</subelem> </subarr> </elem> <elem mod="mstring2" rp="rstring2"> <subarr> <subelem>...</subelem> <subelem>...</subelem> </subarr> </elem> ... </arr> ...
In particular, mod and rp become attributes. Now my question: Is it possible to configure XMLout in a way, so that rp is turned in an attribute, but mod is turned into a element, i.e.
... <arr> <elem rp="rstring1"> <mod>mstring1</mod> <subarr> <subelem>...</subelem> <subelem>...</subelem> </subarr> </elem> <elem rp="rstring2"> <mod>mstring2</mod> <subarr> <subelem>...</subelem> <subelem>...</subelem> </subarr> </elem> ... </arr> ...
Can this be done with XMLout, or is XML::Simple too, eh, simple for this task?

-- 
Ronald Fischer <ynnor@mm.st>

In reply to XML::Simple : element vs. attribute in XMLout by rovf

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.