473,320 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

why doesn't nodeValue work?

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? Both it and textContent work when using PHP's DOM object:

http://www.frostjedi.com/terra/scripts/demo/xml.phps
http://www.frostjedi.com/terra/scripts/demo/xml.php5
Dec 7 '07 #1
7 6174
VK
On Dec 7, 11:44 pm, yawnmoth <terra1...@yahoo.comwrote:
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?
Dec 7 '07 #2
On Dec 7, 4:07 pm, VK <schools_r...@yahoo.comwrote:
[snip]
>
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?
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.)
Dec 8 '07 #3
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

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?
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!
Dec 8 '07 #4
On Dec 8, 12:13 am, yawnmoth <terra1...@yahoo.comwrote:
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
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.
Dec 8 '07 #5
On Dec 8, 10:55 am, David Mark <dmark.cins...@gmail.comwrote:
On Dec 8, 12:13 am,yawnmoth<terra1...@yahoo.comwrote:
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
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.
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.
Dec 8 '07 #6
yawnmoth wrote:
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
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
Dec 8 '07 #7
On Dec 8, 2:33 pm, yawnmoth <terra1...@yahoo.comwrote:
On Dec 8, 10:55 am, David Mark <dmark.cins...@gmail.comwrote:


On Dec 8, 12:13 am,yawnmoth<terra1...@yahoo.comwrote:
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
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.

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.

Dec 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chewy509 | last post by:
Hi Everyone, I'll just start, and say I am not a PHP developer (I'm a sysadmin, who has gotten lumped with a non-working website). But since I like to do this type of stuff, I though I might...
0
by: emes | last post by:
hi all, i'm developing an application in gtk (+glade). i have to intercept any modification of gtk.TextView widget contents. using glade, i connected following signals to callback method: ...
4
by: Chris Lount | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm pretty new to c++ . I'm trying to work out why the following code doesn't work. I've just learned about cin.get() and written the following...
3
by: OM | last post by:
Why doesn't a onmouseover function work in a function? (It's prob due to my code being wrong more than anything else!) I've got the following code (snippet): <!-- Begin var image0 = new...
6
by: JustSomeGuy | last post by:
unsigned short x; ifstream cin; // opened in binary mode. cin >> x; // Doesn't work. yet cin.read((char *) &x, sizeof(x)); works...
3
by: Iver Erling Årva | last post by:
Can anyone please tell me why this doesn't work? The sign changes when I hit the button, and I get no error messages, but the textarea doesn't disappear/reappear. <html> <head> <title>New...
10
by: Brett | last post by:
This code is supposed to work in Netscape 4+ and IE 4+. It works fine in IE but in Netscape 7.2, I get a blank page. Any suggestions? Thanks, Brett <html> <head>
3
by: MeNotHome | last post by:
I am trying to automate web browser navigation and form fill out in vb.net Why doesn't this work? AxWebBrowser1.Document.Forms(0).All("action-download").click() I also tried...
3
by: Joey | last post by:
I am working on an asp.net 1.1 web app in C#. I downloaded some sample code that is supposed to allow for me to persist session state. The code is as follows: private void PersistSessionState()...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.