Page 1 of 1

Referencing an empty node

Posted: Sat Oct 24, 2009 1:45 pm
by jeffmatthews
How to access?

1. This works: <name>Joe</name>

nameElement[0].firstChild.nodeValue returns "Joe"

2. This does not work: <name></name>

nameElement[0].firstChild.nodeValue creates an error.

I have tried using a boolean operator to evaluate it (if nameElement....), but that does not work, either.

So, how am I to ever figure out I have an empty text tag?

Re: Referencing an empty node

Posted: Sat Oct 24, 2009 2:00 pm
by jeffmatthews
Matt's a busy guy! :roll:

I found the answer. Must test: if (name[0].firstChild)...

What a joke! Who wrote the program to require such extraneous evaluations? It should just return null or an empty string, or whatever.