Like everyone else has noted, the inital entry by JackHammer into the XML::Simple doc is wrong. But the neat thing is that if he only had one QuestionList it would work. Why, you ask? Because that is what you told XML::Simple to do. If there is more than one element by the same name then you get an arrayref, otherwise you get a hash. Sounds like code breaking behaviour to me, I guess XML::Simple is broken like that. Fear not, for those lovely folks that wrote XML::Simple saw that and said: "Let there be a standardization switch in XML::Simple", and then there was. Its just not turned on in a simple Simple doc hash. As far as Perl screeching about being Out of memory!, it's better than "Core dumped" but isn't it the same sort of invalid reference problem? Perl should wretch, but it ought to leave with some parting words, IMHO. But that's for the Perl core hackers, I do well just to make things work at all. What you want is for XML::Simple to to always make the hashrefs point to an arrayref, whether there is one or more items. Instantiate your Simple doc like this and everything will be in a standardized data set.
my $xml_ref = XMLin($xml, keyattr='');
So your freshly parsed doc with a single QuestionList looks like this:
[crash@shadowfax crash]$ ./this.pl $VAR1 = { 'QuestionList' => [ { 'Question' => { 'Text' => 'Are dingos +your friend?', 'Id' => '3', 'Answer' => 'Satisfact +ory' } }, {} ] }; Satisfactory[crash@shadowfax crash]$
One of the projects I have worked on was a simple cXML system, and I am using XML::Parser::Checker and XML::Simple along with a data mapping hash to mask out the data from the documents we get in. I ran into the same problem trying to get that to work. Hope this clears things up with that.

In reply to Re: XML Parsing Out of Memory error by msemich
in thread XML Parsing Out of Memory error by JackHammer

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.