in reply to XML::Simple - repeated child elements does not give list of hashes

In my experience, the answer to 99% of XML::Simple questions is "use the ForceArray option".

--

See the Copyright notice on my home node.

"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg

  • Comment on Re: XML::Simple - repeated child elements does not give list of hashes

Replies are listed 'Best First'.
Re^2: XML::Simple - repeated child elements does not give list of hashes
by isync (Hermit) on Mar 23, 2007 at 18:00 UTC
    You are right, and I already tried it:
    "forcearray => 1" does an unwanted "all"
    "forcearray => [ 'node' ]" does nothing, just ignored - can somebody explain to me why? Is my data structure wrong?? As test:
    "forcearray => [ 'key1' ]" works and outputs "key1" as a one-item array...

    I am running XML::Simple v2.03 (can't upgrade)
      Most things in perl are case sensitive. So: use 'ForceArray', not 'forcearray'.
        I know! Actually I found out that with my version 2.03 of XML::Simple only "forcearray" works, as it is case-sensitive to lc! ;-)

        But I just solved the problem myself. A missing keyattr (in lower case btw) was it. Using XMLin() with "forcearray => 'node', keyattr => 'node' did the trick!

        Anyway, big thanks to the monks of perl. May this thread grow the wisdom in the monastery...