Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Parsing XML

by calebcall (Sexton)
on Mar 11, 2014 at 01:53 UTC ( [id://1077775]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-16 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found