Thanks in advance for any pointers, basically, I'm trying a simple Javascript program to retrieve data from a .XML file with DOM. The W3C Schools website gives me this example,
So that should return the price, or if I change that value to say 'author' it returns the author. Simple!
So I saved the books.xml to my hard drive and copied that code into notepad and saved it as test.html. But when I run it locally, nothing happens?!
I have Apache running as well.
Any ideas please?
Thanks!!!
EDIT: Here's the link where you can run the example,
http://www.w3schools.com/dom/dom_nodes_get.asp
http://www.w3schools.com/dom/tryit.asp?filename=try_dom_getelementsbytagname
Code:
<html>
<head>
<script type="text/javascript" src="loadxmldoc.js">
</script>
</head>
<body>
<script type="text/javascript">
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('price');
for (i=0;i<x.length;i++)
{
document.write(x[i].childNodes[0].nodeValue)
document.write("<br />")
}
</script>
</body>
</html>
So that should return the price, or if I change that value to say 'author' it returns the author. Simple!
So I saved the books.xml to my hard drive and copied that code into notepad and saved it as test.html. But when I run it locally, nothing happens?!

Any ideas please?
Thanks!!!
EDIT: Here's the link where you can run the example,
http://www.w3schools.com/dom/dom_nodes_get.asp
http://www.w3schools.com/dom/tryit.asp?filename=try_dom_getelementsbytagname
Last edited: