Error: Attempt to use null DOM node

I’m using the DOM parser to write information into a Notes database. I keep getting “Attempt to use null DOM node” if the XML attribute is blank. There are times when the attribute will be blank.

So far I’ve tried:

If SoapEnv.GetElementsByTagName(“ShortName”).GetItem(1).isnull

If SoapEnv.GetElementsByTagName(“ShortName”).NodeValue = “”

Set SN = SoapEnv.GetElementsByTagName(“ShortName”).GetItem(1)

If SN.FirstChild.NodeValue= “”

and none of these catch the error. It errors out on the next line:

doc.ShortName = SN.FirstChild.NodeValue

so I need to check for null before I do this.

How can I check for null?

Subject: Error: Attempt to use null DOM node

The NotesDOMNode and its derived classes is a wierdo – check using nodeVariable.IsNull. Coincidentally, I just blew most of the weekend finding that little tidbit out.

Subject: RE: Error: Attempt to use null DOM node

Thanks, Stan.

Where did you find the tidbit??

I’ve looked for info on parsing xml & DOM node and find the Help a little lacking.

Subject: RE: Error: Attempt to use null DOM node

I finally broke down and read the whole NodtesDOMNode entry in Designer Help. The places you’d expect to find it – NextSibling, etc., just say that it will throw a null. Well, the obvious answer is to use Isnull(whatever), but that throws a 4750 error (lserr_NOTES_NULL_DOMNODE). So you think, “Hey, it’s an object, and null objects are Nothing!”, so you use Do Until whatever Is Nothing and get another 4750. Frustration finally reaches the point where you are willing to R every word of TFM.

Subject: RE: Error: Attempt to use null DOM node

I’ve read most of it, too. I’ve learned a lot, but not enought.

I’m still having a problem. I thought I was testing for null in the 1st statement, but it does the else and errors on the Set statement.

Dim FN As NotesDOMElementNode

			If SoapEnv.GetElementsByTagName("FirstName").GetItem(1).isnull Then

			Else

				Set FN = SoapEnv.GetElementsByTagName("FirstName").GetItem(1)

				doc.FirstName= FN.FirstChild.NodeValue

						FN.FirstChild.NodeValue = ""

			End If

It’s still not seeing the isnull. Any ideas?

Subject: RE: Error: Attempt to use null DOM node

I haven’t had a whole lot of success with long “dot chains” – for the most part, I’ve found that I need to assign to a NotesDOMxxxx object before I could get very far. In the example you’ve given, I’d probably throw GetElementsByTagName to a NotesDOMNodeList explicitly, then throw GetItem to a NotesDOMNode before testing. Verbosity is key. If you still have feeling in your fingers, there’s a reference chain somewhere that needs to be split into objects ;o)

Subject: RE: Error: Attempt to use null DOM node

That seems to be working. Too bad we can’t do it in one step instead of breaking it down like that.

Thanks for the help.