i'm sorry if this is a very basic question but i'm really stuck here and i don't have much time. so i created an xml file with data in it and want to display it in html using javascript, but all i get is a blank page. this is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<text>
<content> a random text </content>
</text>
and that's my html file xml
<script>
document.write("begin");
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","text.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("text");
document.write(x[i].getElementsByTagName("content") [0].childNodes[0].nodeValue);
</script>
</body>
</html>
maybe it uses httpRequest so it needs a server, but i tried apache and it did not work. thanks for helping me
Aucun commentaire:
Enregistrer un commentaire