Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: XML::Simple hash tree structure not consistent

by ferreira (Chaplain)
on Mar 29, 2007 at 18:32 UTC ( #607322=note: print w/replies, xml ) Need Help??


in reply to XML::Simple hash tree structure not consistent

I can't seem to get XML:Simple to create a hash tree the same way for different data. If there are two entries in my tree then I get named hashes of named hashes. If the XML only has one entry then the structure changes. How do I force the same structure all the time?

That's pretty common in XML::Simple usage and the reason why there's ForceArray (see this section).

XMLin($xml, ForceArray => [ qw(state project) ] );
The names in ForceArray stand for those tags which should always be transformed into array refs, no matter if only one appears. It is all explained in the fine documentation, including this FAQ.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://607322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-10-16 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?