simon_stocks
09-01-2003, 12:25 PM
I have been trying to get this javascript working for a while now, its an XML parser for a news feed.
Basically, I needed something that would parse the information, so that I could insert that target=_blank statement in the URL, as direct linking to the news source didn't open a new window.
The script is as follows
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
function loadXML(xmlFile) {
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.load(xmlFile);
}
function verify() {
if(xmlDoc.readyState!=4)
return false;
}
function traverse(tree,vars) {
tempVar=vars
//if (tempVar != "") { alert(tempVar) }
if(tree.hasChildNodes()) {
var title = tree.getAttribute("name")
if (title=='Title') { tempVar=tree.text }
if (title=="Description") { document.write(tree.text+'</p>') }
if (title=="Link"){ document.write('<a href="'+tree.text+'" target="_blank">'+tempVar+'</a><br>') }
var nodes=tree.childNodes.length;
for(var i=0; i<tree.childNodes.length; i++)
traverse(tree.childNodes(i), tempVar);
}
}
function initTraverse(file) {
loadXML(file);
var doc=xmlDoc.documentElement;
traverse(doc,'nothing');
}
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="initTraverse('http://www.deadbrain.co.uk/synd/syndicate.xml')">
</body>
</html>
--------------------------------------------------------------------
If I run it locally on my machine, it works fine, but as soon as I load it onto the web server, it comes up with the Access is Denied message.
Any help would be greatly appreciated.
Thanks
Simon:confused:
Basically, I needed something that would parse the information, so that I could insert that target=_blank statement in the URL, as direct linking to the news source didn't open a new window.
The script is as follows
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
function loadXML(xmlFile) {
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.load(xmlFile);
}
function verify() {
if(xmlDoc.readyState!=4)
return false;
}
function traverse(tree,vars) {
tempVar=vars
//if (tempVar != "") { alert(tempVar) }
if(tree.hasChildNodes()) {
var title = tree.getAttribute("name")
if (title=='Title') { tempVar=tree.text }
if (title=="Description") { document.write(tree.text+'</p>') }
if (title=="Link"){ document.write('<a href="'+tree.text+'" target="_blank">'+tempVar+'</a><br>') }
var nodes=tree.childNodes.length;
for(var i=0; i<tree.childNodes.length; i++)
traverse(tree.childNodes(i), tempVar);
}
}
function initTraverse(file) {
loadXML(file);
var doc=xmlDoc.documentElement;
traverse(doc,'nothing');
}
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="initTraverse('http://www.deadbrain.co.uk/synd/syndicate.xml')">
</body>
</html>
--------------------------------------------------------------------
If I run it locally on my machine, it works fine, but as soon as I load it onto the web server, it comes up with the Access is Denied message.
Any help would be greatly appreciated.
Thanks
Simon:confused: