--Updated Code to make it...more simple--
Kind of a strange situation, according to w3schools my code should work, but for some reason it doesn't...connect. Here's my code for my java script.
XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
</head>
<body>
<p id="intro">Hello</p>
<script type="text/javascript" id="announce" src="announce.js"></script>
</body>
</html>
JavaScript
/*jscript*/
var newannouncement = document.createElement('p');
newannouncement.id = 'announcing';
newannouncement.appendChild(document.createTextNode('Here is an announcement'));
var scr = document.getElementById('announce');
scr.parentNode.insertBefore(newannouncement, scr);
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
**xmlhttp.open("GET", "catalog.xml",false);**
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("cd");
for (i=0; i<x.length; i++)
{
alert("for")
}
XML
<?xml version="1.0"?>
<catalog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="catalog.xsd">
<cd>
<author>Ferdi</author>
<date>1192</date>
</cd>
<cd>
<author>JRR</author>
<date>1995</date>
</cd>
</catalog>
Update 1
Due to the fact that I considered the previous code, too confusing, I've changed it to make it simpler so that I can actually find out what the heck is cracking off. The problem appears to be the xmlhttp.open() as the for loop doesn't run. I've switched to xhtml as it keeps the code...easier to read (for me) and I understand that document.write() doesn't work.
The problem
I simply just call the function in-line. The *'s indicate the line that fails. Now, I've tried just leaving it as announce.xml (leaving the announce.xml in same directory) and I've now tried moving it down a directory. I've also tried adding /../ but to no avail.
I didn't see any 'technical' requirements on the w3schools website...so I'm assuming like html it works out of the box.
Further notes
If possible if you're going to suggest technology, such as AJAX, could you please describe what it is, what it does and if possible a link to a suitable place to find out more. Thanks