469,924 Members | 1,389 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

XML Document Node Names

Hello. I have a Javascript that gets data from an XML document and
displays it through javascript. The problem is that when I do
all I get is #text. Can you tell me why?

Here is my code:
The Dante-Cubed Standardized Markup Language Javascript API
---[Powered by DCScript]---
Written by Sean M. Hall, Dante, and Peter-Paul Koch
This is the only script we request you ask for permission to use
Permission: dc***@sfhe.cjb.net
if (location.search.indexOf("=") > 2) {
file = location.search.substring(location.search.indexOf( "=")+1);
else {
function getDCSML() {
if (document.implementation && document.implementation.createDocument)
dcfile = document.implementation.createDocument("", "", null);
dcfile.onload = createDisplay;
else if (window.ActiveXObject)
dcfile = new ActiveXObject("Microsoft.XMLDOM");
dcfile.onreadystatechange = function () {
if (dcfile.readyState == 4) createDisplay()
alert('Your browser can\'t handle DCSML. Too bad.');
function createDisplay()
var x = dcfile.getElementsByTagName("DCSML")[0];
var atext = dcfile.getElementsByTagName("Link")[0];
var htext = dcfile.getElementsByTagName("Header")[0];
var ahtext = dcfile.getElementsByTagName("AltHeader")[0];
var pic = dcfile.getElementsByTagName("pic")[0];
var sub = dcfile.getElementsByTagName("subhead")[0];
/*what= new Array();
for (var c=0;x<x.childNodes.length;c++)
what[c] = x.childNodes[1].firstChild.nodeValue;
var othertags = x.childNodes;
var url = atext.getAttribute("URL");
//Below is a list of valid DCSML tags
var tags = new Array("DCSML","Header","AltHeader","Link","pic","s ubhead");
var makeLink = document.createElement("A");
makeLink.href = url;
var makeHeader = document.createElement("H1");
var makeAH = document.createElement("H2");
var mahtext = document.createTextNode(ahtext.firstChild.nodeValu e);
var mhtext = document.createTextNode(htext.firstChild.nodeValue );
var txt = document.createTextNode(atext.firstChild.nodeValue );
var img = document.createElement("IMG");
img.src = pic.getAttribute("url");
var p = document.createElement("P");
var mtxt = sub.firstChild.nodeName;
How odd is this? A script inside a script? I'm branding this a
seperate script, because of its importance. It sorts the DCSML
document tags, and creates arrays for existent and non-existant tags.
//Begin DCScript Tag-Sorter
not_tags= new Array();
is_tag= new Array();
for (var i=0;i<tags.length;i++)
var checktags = dcfile.getElementsByTagName(tags[i]);
if (checktags[0] == null) {
not_tags[i] = tags[i]
else {
is_tag[i] = tags[i];
//End tag-sorter

//Ugh it's gonna be a bitch sorting this out...
document.body.innerHTML+='<span style="font-size: 13pt; font-family:
verdana; font-weight:

normal; text-align: left; color: #666666; letter-spacing:
document.body.innerHTML+=dcfile.getElementsByTagNa me("subhead")[0].nextSibling.firstChild.nodeValue;

Thank you, Dante.
Jul 20 '05 #1
4 1856
I think more important to see the source document your are scripting
with. Can you post <subhead> block's foo with a couple of lines above
and below?
Jul 20 '05 #2

the name of the node is #text (because the first child is a
text-node), I think you want the value, try .nodeValue :)


Jul 20 '05 #3
nope. nodeValue gives the text inside the tag. I solved the problem:
dcfile.getElementsByTagName("subhead")[0].nodeName gives what I want.

Thanks anyway.
Jul 20 '05 #4
Dante wrote:
nope. nodeValue gives the text inside the tag.

You meant it retrieves the text content of the element. Inside a <tag>
are the tag name, optional attribute identifiers and (depending on the
markup language) optional values, and special punctuators like `=' and
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ron Harter | last post: by
13 posts views Thread by Stumped and Confused | last post: by
5 posts views Thread by Paw Pedersen | last post: by
7 posts views Thread by martinfrompi | last post: by
reply views Thread by gnewsgroup | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.