in reply to getAttribute() of XML::XPath::Node

I did not find getAttribute() method defined in XML::XPath::Node module.
Oh, but it is there.
sub getAttribute { return; }
That is a stub, because the node class is not intended to be used directly. It is the motherclass (or superclass or parent class) for all the different element types. You will always get an instance of XML::XPath::Node::Element, XML::XPath::Node::Comment etc. Try print ref($node), "\n"; and see what it says.


holli

When you're up to your ass in alligators, it's difficult to remember that your original purpose was to drain the swamp.

Replies are listed 'Best First'.
Re^2: getAttribute() of XML::XPath::Node
by Herkum (Parson) on Jan 22, 2009 at 18:24 UTC

    I have found the documentation of XML::XPath to be spotty so you generally have to dig around the code from time to time to verify that the thing you are requesting is what you expect.

    Using the above example, I wish they had used a die statement rather than a return statement because it implies something that is not there. I normally use an empty return as a sign of failure in my code, but you cannot rely upon that assumption in cpan or other peoples code.