rogerio Posted June 3, 2009 Share Posted June 3, 2009 Before I begin, yes I saw the comment "// IE 5 and IE 6". "The following code is from http://www.w3schools.com/xml/xml_examples.asp and works in Firefox but not IE7, why? Thanks...One note, if I try to use the code in MS Office scripting, I get an error for "Line 11, Column 3", i.e. "xmlDoc.send("");". <html><head><script type="text/javascript">function loadXMLDoc(dname){var xmlDoc;if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET",dname,false); xmlDoc.send(""); return xmlDoc.responseXML; }// IE 5 and IE 6else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load(dname); return xmlDoc; }alert("Error loading document");return null;}</script></head><body><h1>W3Schools Internal Note</h1><p><b>To:</b> <span id="to"></span><br /><b>From:</b> <span id="from"></span><br /><b>Message:</b> <span id="message"></span><script type="text/javascript">xmlDoc=loadXMLDoc("note.xml");document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].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></body></html> Link to comment Share on other sites More sharing options...
boen_robot Posted June 4, 2009 Share Posted June 4, 2009 I'm honestly not sure why are you getting this error... try it with this: function loadXMLDoc(dname) { var xmlDoc = window.XMLHttpRequest ? new window.XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLDOM") : null); if (xmlDoc == null) return null; xmlDoc.open("GET", dname, false); xmlDoc.send(null); return xmlDoc.responseXML;} Link to comment Share on other sites More sharing options...
rogerio Posted June 4, 2009 Author Share Posted June 4, 2009 Hi boen_robot, I gave your suggestion a try, but no success. The "Try it" example works, but it appears to be running via .asp. Link to comment Share on other sites More sharing options...
rogerio Posted June 8, 2009 Author Share Posted June 8, 2009 The answer to this problem is that the code "must" be in a .asp, not .html. On to the next W3Schools issue... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.