in reply to xml simple not a hash reference
If you look a bit more closely at your data, you'll notice that data/bb/roomtypes/roomtype is an arrayref holding a hashref. So I'd suspect that your code is trying to do something like:
$hrXml->{data}{bb}{roomtypes}{roomtype}{$aKey};
instead of:
$hrXml->{data}{bb}{roomtypes}{roomtype}[$anIndex]{$aKey};
Note: I've seen a couple other array references in your data too, but I only mentioned the first one. So your error may be coming from one of the others. Also, if you're going to post a chunk of data like that, you should indent your data using less whitespace to make it a bit more readable.
I've heard about XML::Simple having an option (ForceArray) to force certain keys to always use an array reference. I believe (having never used it) that it'll use an array reference if the key has multiple sub-values and a hash reference if the key has only one. That can make your code a little tricky. But if you use ForceArray for the keys that may change on you, then your code can be simplified. (Anyway, that's what I gather from several posts. I'm sure someone will correct me if I misunderstood.)
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: xml simple not a hash reference
by Noverast (Initiate) on Dec 28, 2010 at 13:50 UTC | |
by Anonyrnous Monk (Hermit) on Dec 28, 2010 at 15:00 UTC | |
by Noverast (Initiate) on Dec 29, 2010 at 08:27 UTC | |
by Noverast (Initiate) on Dec 29, 2010 at 07:40 UTC | |
by morgon (Priest) on Dec 29, 2010 at 07:51 UTC | |
by Anonymous Monk on Dec 29, 2010 at 09:10 UTC | |
by Noverast (Initiate) on Dec 29, 2010 at 08:09 UTC | |
by Anonymous Monk on Dec 29, 2010 at 06:22 UTC |