Jump to content

xml and ie explorer 6


Guest johnmce

Recommended Posts

Guest johnmce

Having problems with xml. I am a newbie. I have worked my way through the tutorials and have tried the example at the following address. http://www.w3schools.com/dom/tryit.asp?fil...om_getattributeIt works in the tryit editor but not in internet explorer or firefox. I have saved this file as note.html and the other file as note.xml When I run the html it is blank. Any suggestions.

Link to comment
Share on other sites

I don't get it... it works in the tryit editor but...when you save the code on the left as note.html:

<html><head><script type="text/javascript">var xmlDocfunction loadXML(){//Code for IEif (window.ActiveXObject)  {  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  xmlDoc.async=false;  xmlDoc.load("note.xml");  getmessage()  }//Code for Mozillaelse if (document.implementation && document.implementation.createDocument)  {  xmlDoc=document.implementation.createDocument("","",null);  xmlDoc.load("note.xml");  xmlDoc.onload=getmessage  }else  {  alert('Your browser cannot handle this script');  }}function getmessage(){var x=xmlDoc.getElementsByTagName("note")document.write(x.item(0).getAttribute("time"))}</script></head><body onload="loadXML()"></body></html>

And have this XML file in the same folder:

<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><note time="12:03:46">  <to>Tove</to>  <from>Jani</from>  <heading>Reminder</heading>  <body>Don't forget me this weekend!</body></note>

It should work :) .

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