W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

RE: nullpointer

From: Tom Leuntjens <tom.leuntjens@bricsnet.com>
Date: Thu, 31 May 2001 16:27:49 +0200
To: "Www-Dom@W3. Org" <www-dom@w3.org>
Message-ID: <CCEMJKFFPGIIBIDNEKHIOENJCDAA.tom.leuntjens@bricsnet.com>

>>Are you sure companyname.item() isn't null?
>>Are you sure companyname.item().getFirstChild() isn't null?

yes it would be null .

it would be peferctly possible that  the companyname tag in the xml would be

so no date is in there .

or that the  <companyname> tag would simply not be there

in my xml file i have a bunch of attributes defined to company

so  simple example

	<companyname> Bricsnet </companyname>
	<email> tom@bricsnet.be </email>
	<phone> 548438493340 </phone>


but any of these can be empty or not existing.

>>You should probably test those before testing companyname.item

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.


-----Original Message-----
From: www-dom-request@w3.org [mailto:www-dom-request@w3.org]On Behalf Of
Tom Leuntjens
Sent: Thursday, May 31, 2001 10:39 AM
To: www-dom@w3.org
Subject: nullpointer

Fairly Simple Question,

How do I make sure I don't get a null pointer exception (when the XML
document has  <companyname></companyname> using this code.
Documentation states this should be a null value


   if (companyname.item(i).getFirstChild().getNodeValue() != null) {

      NodeList companyname = doc.getElementsByTagName("companyname");
      String CompanyName =
      out.print(CompanyName + "<br>");


Doesn't do the trick

And all resources on internet with good tutorials using JSP/DOM/XML are


-----Original Message-----
From: www-dom-request@w3.org [mailto:www-dom-request@w3.org]On Behalf Of
Dylan Schiemann
Sent: Wednesday, May 30, 2001 11:19 PM
To: www-dom@w3.org
Subject: range insertNode, what exception should be thrown?

Consider the following JavaScript syntax:

var x = document.createRange();

Suppose that the document does not contain any div
elements.  What exception should be thrown?  Do you
have to check for existence of the node before you
insert it?


Dylan Schiemann

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/
Received on Thursday, 31 May 2001 10:28:54 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC