Re: why doesn't nodeValue work?



On Dec 7, 11:44 pm, yawnmoth <terra1...@xxxxxxxxx> wrote:
http://www.frostjedi.com/terra/scripts/demo/xml.html

The first alert() shows the XML that the server is returning. The
second alert() shows a particular elements nodeValue and, as you can
see, outputs "null". The third alert() shows a particular elements
textContent. Atleast in Firefox. In Internet Explorer it returns
"undefined".

textContent not working I can understand. Internet Explorer probably
just doesn't implement it. But what about nodeValue? Why doesn't
that work?

If you check
xmlHttp.responseXML.getElementsByTagName("a")[0].nodeType
it will report 1 which is type of an ELEMENT_NODE as any value table
tells us

Both Gecko and IE are very explicit that for element nodes nodeType is
null, so they do exactly what is written:
http://msdn2.microsoft.com/en-us/library/ms534192.aspx
http://developer.mozilla.org/en/docs/DOM:element.nodeValue

Another thing is that the whole behavior
xmlHttp.responseXML.getElementsByTagName("a")[0].nodeValue == null
doesn't have any sense to me, even if it's twenty times standard
compliant: but it is maybe because I am missing something important
out of the Big Picture. It would be nice to have some comments on it
from XML parsing experts. And btw indeed how to get "Hello," from <a>
in more or less cross-browser way?
.



Relevant Pages