473,549 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6198
VK
On Dec 7, 11:44 pm, yawnmoth <terra1...@yaho o.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.respons eXML.getElement sByTagName("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.respons eXML.getElement sByTagName("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...@y ahoo.comwrote:
[snip]
>
Another thing is that the whole behavior
xmlHttp.respons eXML.getElement sByTagName("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.respons eXML.getElement sByTagName("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...@yaho o.comwrote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@ gmail.comwrote: Another thing is that the whole behavior
xmlHttp.respons eXML.getElement sByTagName("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<ter ra1...@yahoo.co mwrote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@ gmail.comwrote: Another thing is that the whole behavior
xmlHttp.respons eXML.getElement sByTagName("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.respons eXML.getElement sByTagName("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...@yaho o.comwrote:
On Dec 8, 10:55 am, David Mark <dmark.cins...@ gmail.comwrote:


On Dec 8, 12:13 am,yawnmoth<ter ra1...@yahoo.co mwrote:
On Dec 7, 5:55 pm, David Mark <dmark.cins...@ gmail.comwrote: Another thing is that the whole behavior
xmlHttp.respons eXML.getElement sByTagName("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
7195
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 just learn WTF is going on? :) Basically, sessions are being created, but no info in being stored in the session, and if data is stored (about 1 in...
0
1441
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: insert_at_cursor delete_from_cursor paste_clipboard
4
3835
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 program to enter a string and store it in an array. When I run the program it asks for the first string and then prints it. However, it doesn't...
3
9631
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 Image(); image0.src = "blank.jpg"; var image1 = new Image(); image1.src = "map.jpg"; // End -->
6
421
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
1669
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 Page 1</title> </head>
10
1545
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
5935
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 AxWebBrowser1.Document.Forms(0).All.item("action-download").click() "action-download" is the name of a submit button
3
2721
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() { int MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000; string Script = @" <script type='text/javascript'> var Count=0;
0
7524
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.