Hi all, I’m just to loop through an xml file and append it to a p tag via inner HTML. I’m not getting any errors, but I output one peice of data from the xml instead of everything, I’m a little lost ? Any help/advice would be greatly appreciated.
[code]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script type=”text/javascript”>
function makeRequest(url) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari …
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType(‘text/xml’);
// see note below about this line
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {
try {
http_request = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e) {}
}
}
if (!http_request) {
alert(‘giving up 🙁 cannot create XMLHTTP instance’);
return false;
}
http_request.onreadystatechange = function() { alertContents(http_request); };
http_request.open(‘GET’, url, true);
http_request.send(null);
}
function alertContents(http_request) {
try {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var xmlDoc = http_request.responseXML;
var root_node = xmlDoc.getElementsByTagName(‘euLocales’);
var area2load = document.getElementById(‘print2Screen’);
for (var j = 0; j < root_node.length; j++) {
for (var i = 0; i < root_node[j].childNodes.length; i++) {
area2load.innerHTML = root_node[j].childNodes[i].nodeValue;
}
}
//area2load.innerHTML = root_node.firstChild.data;
} else {
alert(‘there was a problem with the request.’);
}
}
}
catch (e) {
alert(‘caught exception: ‘ + e.description);
}
}
window.onload = function() {makeRequest(‘dp.xml’)};
</script>
</head>
<body>
<p id=”print2Screen”></p>
</body>
</html>