why doesn't nodeValue work? 
December 7th, 2007, 09:15 PM
| | | | re: why doesn't nodeValue work?
On Dec 7, 11:44 pm, yawnmoth <terra1...@yahoo.comwrote: Quote: 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...ment.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? | 
December 8th, 2007, 12:05 AM
| | | | re: why doesn't nodeValue work?
On Dec 7, 4:07 pm, VK <schools_r...@yahoo.comwrote:
[snip] Quote:
>
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
| You are missing the fact that text nodes are not part of element
nodes. What would you propose the nodeValue of an element node
return? Quote:
from XML parsing experts. And btw indeed how to get "Hello," from <a>
in more or less cross-browser way?
| Can't get blood from stone. If you meant:
<a>Hello,</a>
Then you should know how to get "Hello," from that (the nodeValue
property of the first child of the element node.) | 
December 8th, 2007, 05:15 AM
| | | | re: why doesn't nodeValue work?
On Dec 7, 5:55 pm, David Mark <dmark.cins...@gmail.comwrote: Quote: Quote:
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
| >
You are missing the fact that text nodes are not part of element
nodes. What would you propose the nodeValue of an element node
return?
| In PHP, it seems to return the text node... is PHP wrong? Quote: Quote:
from XML parsing experts. And btw indeed how to get "Hello," from <a>
in more or less cross-browser way?
| >
Can't get blood from stone. If you meant:
>
<a>Hello,</a>
>
Then you should know how to get "Hello," from that (the nodeValue
property of the first child of the element node.)
| That "first child" bit helped. Thanks! | 
December 8th, 2007, 05:05 PM
| | | | re: why doesn't nodeValue work?
On Dec 8, 12:13 am, yawnmoth <terra1...@yahoo.comwrote: Quote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@gmail.comwrote: Another thing is that the whole behavior Quote: Quote:
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
| | > Quote:
You are missing the fact that text nodes are not part of element
nodes. What would you propose the nodeValue of an element node
return?
| >
In PHP, it seems to return the text node... is PHP wrong?
| Some DOM implementation for PHP returns a text node for the nodeValue
of an element? Yes, that is wrong. | 
December 8th, 2007, 07:35 PM
| | | | re: why doesn't nodeValue work?
On Dec 8, 10:55 am, David Mark <dmark.cins...@gmail.comwrote: Quote:
On Dec 8, 12:13 am,yawnmoth<terra1...@yahoo.comwrote:
> Quote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@gmail.comwrote: Another thing is that the whole behavior Quote:
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
| | > Quote: Quote:
You are missing the fact that text nodes are not part of element
nodes. What would you propose the nodeValue of an element node
return?
| | > Quote: |
In PHP, it seems to return the text node... is PHP wrong?
| >
Some DOM implementation for PHP returns a text node for the nodeValue
of an element? Yes, that is wrong.
| I wouldn't say it's just "some" random implementation that's doing
this - it's the implementation that's included with PHP's main
distribution: http://www.php.net/manual/en/ref.dom.php
ie. it's pretty much the "official" PHP implementation. | 
December 8th, 2007, 08:45 PM
| | | | re: why doesn't nodeValue work?
yawnmoth wrote: Quote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@gmail.comwrote: Quote: Quote:
>>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
| >You are missing the fact that text nodes are not part of element
>nodes. What would you propose the nodeValue of an element node
>return?
| In PHP, it seems to return the text node... is PHP wrong?
| PHP (5)'s DOM extension implements the `nodeValue' property of DOMElement
objects, apparently for convenience, to yield the concatenated node values
of the descendant text nodes of the element node, like the `textContent'
property from W3C DOM Level 3 that it also implements: http://php.net/DOM
But since it also implements `textContent', `nodeValue' should not yield the
same value. In fact, the value that is yielded there contradicts with W3C
DOM Level 2+ Core that says the `nodeValue' property of objects implementing
the Element interface should have the value `null': http://www.w3.org/TR/DOM-Level-3-Cor...#ID-1950641247
If it was the intention to implement that interface, that would mean PHP is
wrong here, indeed.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann | 
December 8th, 2007, 09:25 PM
| | | | re: why doesn't nodeValue work?
On Dec 8, 2:33 pm, yawnmoth <terra1...@yahoo.comwrote: Quote:
On Dec 8, 10:55 am, David Mark <dmark.cins...@gmail.comwrote:
>
>
>
>
> Quote: |
On Dec 8, 12:13 am,yawnmoth<terra1...@yahoo.comwrote:
| > Quote: Quote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@gmail.comwrote: 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
| | > Quote: Quote:
You are missing the fact that text nodes are not part of element
nodes. What would you propose the nodeValue of an element node
return?
| | > Quote: Quote: |
In PHP, it seems to return the text node... is PHP wrong?
| | > Quote:
Some DOM implementation for PHP returns a text node for the nodeValue
of an element? Yes, that is wrong.
| >
I wouldn't say it's just "some" random implementation that's doing
this - it's the implementation that's included with PHP's main
distribution:
> http://www.php.net/manual/en/ref.dom.php
>
ie. it's pretty much the "official" PHP implementation.
| Then the "official" implementation is officially wrong. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|