Jump to content

XML Parsing help


ballhogjoni

Recommended Posts

I am using a script from w3schools and I try to parse an xml file, but I get a javascript error saying "access denied". Can someone help with this problem.

 

my script

<html>
<head>
<script type="text/javascript">
var xmlDoc;
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("http://www.xxxxxxxxx.com/partners/access/xml/xml.asp?uid=xxxxxxxxxxxx");
getmessage();
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("http://www.xxxxxxxxxxxxxx.com/partners/access/xml/xml.asp?uid=xxxxxxxxxx");
xmlDoc.onload=getmessage;
}
else
{
alert('Your browser cannot handle this script');
}
}

function getmessage()
{
document.getElementById("category").innerHTML=xmlDoc.getElementsByTagName("category")[9].childNodes[0].nodeValue;
<!--document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;-->
<!--document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;-->
}
</script>
</head>

<body onload="loadXML()">
<h1>W3Schools Internal Note</h1>
<p><b>To:</b> <span id="category"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
</p>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/72468-xml-parsing-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.