- From: Jim Ley <jim@e-media.co.uk>
- Date: Thu, 31 May 2001 10:43:31 -0400 (EDT)
- To: "Tom Leuntjens" <tom.leuntjens@bricsnet.com>, "Www-Dom@W3. Org" <www-dom@w3.org>
> 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