P is for Practical | |
PerlMonks |
Re: XML Array/Hash Issueby Preceptor (Deacon) |
on Nov 20, 2013 at 21:37 UTC ( [id://1063615]=note: print w/replies, xml ) | Need Help?? |
Your problem is that you're getting a scalar in one mode, and an array in the other - and so your coercion is failing. I would take a slightly different approach, and use XML::Twig, which is my current favorite XML parser.
You could also find the 'children' method within XML::Twig to be handy if you wanted to do it a different way.
The former invokes the subroutine each time the parser hits an 'errors' element. (So twice). The latter invokes the sub just once (for each 'error') but then cycles through the 'errors' within it. (Which is optimal depends on what you're trying to do exactly, which is why I've given both examples).
In Section
Seekers of Perl Wisdom
|
|