Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.