Totally new to XML and I've been struggling on this very simple objective for too long (though I can find enough on the internet about it). Just need the values out of this xml file:
<?xml version="1.0" encoding="UTF-8"?>
<materials>
<basic>
<uurloon>10</uurloon>
<setloon>100</setloon>
</basic>
<extra>
<geluid>150</geluid>
<ledset>35</ledset>
<strobo>20</strobo>
<laser>50</laser>
</extra>
</materials>
In javascript, I use this code to get the xml data:
// load xml file
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else { // IE 5/6
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", "pricing.xml", false);
xhttp.send();
xmlDoc = xhttp.responseXML;
var uurloon = xmlDoc.getElementsByTagName("uurloon")[0].childNodes[0].text;
var setloon = xmlDoc.getElementsByTagName("setloon")[0].childNodes[0].text
alert('end');
No result though, cause I'm not seeing the alert..