mardi 3 mars 2015

Can't get text into variable from XML files using javascript

I have been banging my head over this (probably simple) issue and am missing something really basic. Why does this first code display the expected output



xmlhttp=xmlhttp.responseXML;

document.getElementById("CenterDataBox").innerHTML= xmlhttp.getElementsByTagName("ShowDay")[0].childNodes[0].nodeValue;


and this second one doesn't? I think this is something really simple I've overlooking.



xmlhttp=xmlhttp.responseXML;

var DayOfShow = xmlhttp.getElementsByTagName("ShowDay")[0].childNodes[0].nodeValue;
document.getElementById("CenterDataBox").innerHTML= DayofShow;

Aucun commentaire:

Enregistrer un commentaire