I'm trying to parse a simple xml document using a DOM parser in JS, but the parser can't load the file. I'm using the examples from a popular website and I thought this would work.
All my files are store on my local compter (not using a web server... using file:/// and not http:// ).
my code is
<html>
<head>
</head>
<body>
<script>
<script type="text/javascript">
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else // IE 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","chinese.xml",false);
xhttp.send();
xmlDoc=xhttp.responseXML;
x=xmlDoc.documentElement.childNodes;
for (i=0;i<x.length;i++)
{
document.write(x[i].nodeName);
}
</script>
</body>
</html>
both my hmtl and xml files are located in the same folder. I can't understand why this is not working
xml file is
<!DOCTYPE menu SYSTEM "chinese.dtd">
<menu>
<dish>
<name>Chicken Sweetcorn Soup</name>
<price>1.60</price>
</dish>
<dish>
<name>Spring Roll</name>
<price>1.50</price>
</dish>
<dish>
<name>Special Satay</name>
<ingredients>King Prawn, Chicken, Beef with Vegetables</ingredients>
<price>4.50</price>
</dish>
<dish>
<name>Barbecued Spare Ribs</name>
<price>3.99</price>
</dish>
<dish>
<name>Sweet and Sour Pork</name>
<style>Cantonese</style>
<price>4.49</price>
</dish>
</menu>