XML::Simple seems to be taking some liberties with the code I feed it. Lets say I have xml like this that I put in a data structure my $config = XMLin($configfile);
<config id="Installer"> <pclist> <pc>MYPC1</pc> <pc>MYPC2</pc> <pc>MYPC3</pc> </pclist> <installfrom>C:\install</installfrom> <installto> <path>C:\Program Files</path> <subdir>directory</subdir> </installto> <logon> <domain>mydomain</domain> <user>someuser</user> <pass>blahblah</pass> </logon> </config>
Then I manipulate the structure by adding a pc name with and changing $config->{'installto'}->{'subdir'} = "otherdirectory"; I feed the altered hashref to XMLout($config); and the output is a little different.
<pclist> <pc>MYPC1</pc> <pc>MYPC2</pc> <pc>MYPC3</pc> <pc>MYPC4</pc> </pclist> <logon pass="blahblah" domain="mydomain" user="someuser" /> <installto path="C:\Program Files" subdir="otherdirectory" /> </opt>
Somehow the pclist which refers to an array ref is fine. but the other nested tags get all fubared into single elements. Am I doing something wrong?

In reply to XML formatting problems with XML::Simple by thunders

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.