Shakazahn Posted April 12, 2009 Share Posted April 12, 2009 Hello,I was following w3 tutorial and while trying some examples I got to this: document.getElementById('myBody').innerHTML = xmlDoc.getElementsByTagName('main')[0].childNodes[0].nodeValue; ...which works really fine, but I can't get anything else than that.From the tutorial: * xmlDoc - the XML DOM object created by the parser. * getElementsByTagName("title")[0] - the first <title> element * childNodes[0] - the first child of the <title> element (the text node) * nodeValue - the value of the node (the text itself)So I tried using childNodes[1] to get my 1st subelement (it's a section preview msg) but I couldn't get what was inside it. If I do .nodeName it calls the name correctly though, firstChild/lastChild works also, but I want to create multiple childs and access them through the parentName.Any help please?Edit: My XML file looks like this: <main> mainContent Here etc bla bla bla<mainPreview> this is the main section of the site </mainPreview></main> Link to comment Share on other sites More sharing options...
Shakazahn Posted April 12, 2009 Author Share Posted April 12, 2009 Argh, figured it... document.getElementById('myBody').innerHTML = xmlDoc.getElementsByTagName('main')[0].childNodes[x].childNodes[0].nodeValue; Didn't thought I had to call the child of the child to get it's content... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.