Hey Monks,

I'm using XML::Simple to slurp in, spit out xml for a project that's just in the prototype phase. I'm using the forcearray option as recommended, but I'm noticing something strange that I haven't been able to figure out by looking at the XML::Simple documentation (not saying it ain't in there, just that I can't seem to figure out where).

I'm starting with an xml document that looks like this:

<xml> <class instructor="young" subject="social studies" level="7" id="rm1 +02"> <student id="1"> <first_name>Francis</first_name> <last_name>Bustardo</last_name> </student> <student id="2"> <first_name>Escarlet</first_name> <last_name>Testamente</last_name> </student> <student id="3"> <first_name>Franco</first_name> <last_name>Coolamente</last_name> </student> </class> </xml>

And I'm using XMLin to slurp it in, passing the hashref to XMLout (calling with no options) and outputting the following xml as a result:

<opt> <class level="7" instructor="young" subject="social studies" name="r +m102"> <student name="1"> <first_name>Francis</first_name> <last_name>Bustardo</last_name> </student> <student name="2"> <first_name>Escarlet</first_name> <last_name>Testamente</last_name> </student> <student name="3"> <first_name>Franco</first_name> <last_name>Coolamente</last_name> </student> </class> </opt>

So my questions are:
-why is XML::Simple changing my <xml> to <opt>?
-why is it changing <student id="number"> to <student name="number">?

Thanks for any advice,

AH

p.s. I'm pretty new to xml and it's rules... I've been looking at the hash created using Data::Dumper and see that the resultant data structure doesn't retain the "id" name... can anyone help me figure out how to save that?


In reply to XML::Simple::XMLout() renaming tags by alienhuman

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.