Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Can't call method "getAttribute"

by kyle (Abbot)
on Jul 20, 2009 at 02:40 UTC ( #781508=note: print w/ replies, xml ) Need Help??


in reply to Can't call method "getAttribute"

The only place I see "getAttribute" is in this sub:

sub get_data { my($element, $attribute, $index) = @_; if ($index){$index=1;} my $nodeset = $xp->find("//yweather:$element"); my $node = $nodeset->get_node($index); return $node->getAttribute($attribute); }

The error message means that $node is undef at this point. That means that undef was returned from $nodeset->get_node($index). I see a lot of calls to this sub, but in every case, there's no $index passed. According to the code that's there, that makes $index undef also. That's what I can see without running it.

My guess is that the bit that says "if ($index){$index=1;}" should actually say "if (!$index){$index=1;}" (note the exclamation point). That's just a guess.

To really find out what's going on, I'd recommend running this under the Perl debugger. See perldebug for the gory details.


Comment on Re: Can't call method "getAttribute"
Select or Download Code
Re^2: Can't call method "getAttribute"
by Squeakers (Initiate) on Jul 20, 2009 at 17:12 UTC
    I changed the code according to your recomendations and still get the same error. I tried running the perldebug and this is beyond my noob capabilities. If you could give me a brief of what your looking for and how to get it, i will provide. Thanks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2014-08-28 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls