more useful options | |
PerlMonks |
parsing complex xml structure with xml::simpleby bfdi533 (Friar) |
on Aug 01, 2006 at 14:21 UTC ( [id://564998]=perlquestion: print w/replies, xml ) | Need Help?? |
bfdi533 has asked for the wisdom of the Perl Monks concerning the following question: I have an xml input file that I need to parse and the structure is pretty complex. I have been working my way through the structure fairly well but have run into a situation that I do not know how to handle. I am using code to dereference parts of the xml structure to more easily deal with them. One part is throwing me though. I have a set that is a Row(s) of Detail info that can either contain a hash or an array of hashes. I had been dealing with this as an array of hashes but when it gets to a single hash rather than an array the code crashes with an "Not an ARRAY reference at ..." error. Here is the code: And here is a piece of the data:
How can I go about handling the multiple rows versus the single row situation with efficient code? Is there a way to check to see if a variable is an array a has and execute an if/then/else code segment?
Back to
Seekers of Perl Wisdom
|
|