Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781508]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2017-12-13 04:40 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (345 votes). Check out past polls.