I’m using this code:
<script type="text/javascript">
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","css/galerii.xml",false)
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
alert(xmlDoc.getElementsByTagName("GALERIE")[0].childNodes[0].nodeValue);
</script>
to process some xml:
<?xml version="1.0" encoding="UTF-8" ?>
<GALERIES>
<GALERIE>
info
</GALERIE>
<GALERIE>
other info
</GALERIE>
</GALERIES>
But I get nothing in the alert and shouldn’t xmlhttp.open(“GET”,”css/galerii.xml”,false) have a value if it’s successful ? It’s undefined.
There’s a root node now, same result.
You have no root node (document element), which is a requirement in XML.
You also have no onreadystatechange method for your AJAX request. When your code which reads the responeXML executes, the http request for the XML has yet to return. You need to read up on how to build AJAX requests: https://developer.mozilla.org/en/xmlhttprequest
Working example: http://jsfiddle.net/2F8q6/1/
Your JS modified to work as the example does: