Re: nullpointer

> since I am getting nullpointer exceptions
> and i thought I am testing it using
>
> if (companyname.item(i).getFirstChild().getNodeValue() != null)
>
> apparantly that is not enough.

Nope, and it never is, this is a simple javascript problem because there
are no children to the item (say) then

companyname.item(i).getFirstChild() evaluates to null.
therefore you have

null.getNodeValue() != null
That is not allowed, null has no methods.

You need to test every single object  before calling a method/accessing a
property.

if (companyname && companyname.item && companyname.item(i) &&
companyname.item(i).getFirstChild() &&
companyname.item(i).getFirstChild().getNodeValue())

Would be what you want to do.  (yes I know it's long...)

Jim.

Received on Monday, 4 June 2001 15:48:15 UTC