in reply to Re: Parsing XML
in thread Parsing XML

So this works great if there are multiple items (domains in this case) that return. I've got cases where only a singe domain will return and I get the following error:

Not an ARRAY reference at ./namecheap.pl line 99

Line 99 in the line my foreach loop begins on. In my uneducated opinion, it would be due to returning only a single result and referencing it using @. I've tried a few other stabs at being able to handle both a single and multiple results but can't come up with anything. My next guess is to try to find how long my results are (i.e. greater than one) and handle them separately...but that seems like a lot of redundant work having the exact same thing but for different results.

Replies are listed 'Best First'.
Re^3: Parsing XML
by tangent (Parson) on Mar 11, 2014 at 02:06 UTC
    Did you use ForceArray as McA suggested?

      I did.

      EDIT:

      Ooh, thanks, I just found the issue. I was using the ForceArray, but that was for the first API call. The second one needed a different element specified. Thanks again.

Re^3: Parsing XML (XML::Rules xml2XMLRules )
by Anonymous Monk on Mar 11, 2014 at 02:20 UTC
    That is problem with XML::Simple :) sure there are options but its easier to use XML::Rules , its is XML::Simple on steriods, exampe
      Thanks, guys. I'll give these other modules a look.
Re^3: Parsing XML (XML::LibXML xpather )
by Anonymous Monk on Mar 11, 2014 at 02:42 UTC