I have to load an xml from a url and process the request.
but i am getting error while the url is called for loading.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body onload="readXmlFile()"> <h1>ReadXML</h1> <p> If all goes well you should see an alert box display the message 'testing 123' </p> <p>Press the 'go' button to read the xml file '<a href="test123">test123</a>' from the web server. <input type="button" onclick="readXmlFile()" value="go"/> </p> </body> <script type="text/javascript"> XML.load = function(url) { alert("1"); alert(url); var xmldoc = XML.newDocument(); xmldoc.async = false; xmldoc.load(url); return xmldoc; }; XML.newDocument = function(rootTagName, namespaceURL) { if (!rootTagName) rootTagName = ""; if (!namespaceURL) namespaceURL = ""; if (document.implementation && document.implementation.createDocument) { // This is the W3C standard way to do it return document.implementation.createDocument(namespaceURL, rootTagName, null); } else { // This is the IE way to do it // Create an empty document as an ActiveX object // If there is no root element, this is all we have to do var doc = new ActiveXObject("MSXML2.DOMDocument"); // If there is a root tag, initialize the document if (rootTagName) { // Look for a namespace prefix var prefix = ""; var tagname = rootTagName; var p = rootTagName.indexOf(':'); if (p != -1) { prefix = rootTagName.substring(0, p); tagname = rootTagName.substring(p+1); } // If we have a namespace, we must have a namespace prefix // If we don't have a namespace, we discard any prefix if (namespaceURL) { if (!prefix) prefix = "a0"; // What Firefox uses } else prefix = ""; // Create the root element (with optional namespace) as a // string of text var text = "<" + (prefix?(prefix+":"):"") + tagname + (namespaceURL ?(" xmlns:" + prefix + '="' + namespaceURL +'"') :"") + "/>"; // And parse that text into the empty document doc.loadXML(text); } return doc; } }; function readXmlFile() { url = 'http://open.api.ebay.com/shopping?callname=FindItems&responseencoding=XML&appid=AneeshVK-1af9-4429-99ab-99fa586437ca&siteid=3&version=515&SellerID=timbarson1'; alert(url); doc = XML.load(url); alert(doc); alert(doc.documentElement.firstChild.nextSibling.firstChild.nodeValue); } </script> </html>
the error is
i am running it from xampp. i am badly stuck here and would like to have any advice/help in this. I have to load this xml and process it to take the details to display in the pageCode:Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://localhost/bulbtemplate/abcd.html Line: 26"]
Thanks
Aneesh.V.K



Reply With Quote
Bookmarks