Jump to content

W3schools Xml Tutorial


Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...