hey. I'm trying to get a grasp on XML for use with AJAX.
here is my code. what i want to do is grab the stuff between the 'content' tags, and display it. then i want to take the stuff between the 'script' tags, and eval it (so it will execute).

here is my simple xml document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<myScript> alert("hello world"); </myScript>
<content> This text should be displayed as content. </content>
</document>

and my handleResponse code from the calling page:

function handleResponse(http_request, divID){
   var myDiv = document.getElementById(divID);
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
          myXMLDoc = http_request.responseXML;
          content = myXMLDoc.getElementsByTagName("content");
          myDiv.innerHTML = content; 
   } else {
   alert("There was a problem with the request.");
  }
 }
}

When i run this, i get the error "object doesn't support this property or method" ... and its complaining about the line :
content = myXMLDoc.getElementsByTagName("content");

Can anybody see what I'm doing wrong, and possibly suggest how to fix it? I'm just getting into XML, and it would be a big help
Thanks!

This article has been dead for over six months. Start a new discussion instead.