![]() Topic awaiting preservation: javascript - xml - nodeValue? (Page 1 of 1) |
|
|---|---|
|
Paranoid (IV) Inmate From: San Antonio |
posted 11-11-2005 21:55
Hopefully this is just something easy that I can't find... code: <points>
<point>
<id>first</id>
<lat>29</lat>
<lon>-98</lon>
</point>
.
.
.
</points>
code: var request = GXmlHttp.create();
request.open("GET", "PointsXml.xml", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
//alert(request.responseText);
var xmlDoc = request.responseXML;
//alert("Root node: " + xmlDoc.documentElement.nodeName);
var pointNodes = xmlDoc.documentElement.getElementsByTagName("point");
//alert("Number of point nodes: " + pointNodes.length);
for ( var i = 0; i < pointNodes.length; i++ ) {
var pointNodeChildren = pointNodes.item(i).childNodes;
var childValues = "";
for( var j = 0; j < pointNodeChildren.length; j++ ) {
childValues += j + ". " + pointNodeChildren[j].nodeName + ": " + pointNodeChildren[j].nodeValue + "\r\n";
}
alert(childValues);
}
}
}
request.send(null);
quote:
|
|
Bipolar (III) Inmate From: Umeå, Sweden |
posted 11-11-2005 23:05
It's the whitespace between the tags. The DOM and XML specs don't point in either way being correct, but it's important for things like the CSS white-space property being handled as it should, so the resonable handling of it is to let it stay in the DOM. |
|
Paranoid (IV) Inmate From: San Antonio |
posted 11-11-2005 23:37
It's been awhile since I've done anything web-related, so what you just said all sounded familiar, but it went right by me (probably isn't helping that it's Friday afternoon either). quote:
|
|
Paranoid (IV) Inmate From: San Antonio |
posted 11-11-2005 23:41
Nevermind. I didn't realize that the text node that it was finding was a child of the element node, so you have to get at it like: |