SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: IE8 vs XML

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Location
    India
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE8 vs XML

    Check out the following link.
    http://mssportfolio.com/popup/
    If u click on the "Add to cart" button,a pop up appears with some data retrieved from XML.The pop up works fine in Firefox but not with IE.The pop up appears in IE but not the data from xml file.what may be the problem?The script to retrieve xml code is as follows:

    Code:
    function loadXMLDoc(dname)
    {
    var xmlDoc;
    
    if (window.XMLHttpRequest)
      {
      xmlDoc=new window.XMLHttpRequest();
      xmlDoc.open("GET",dname,false);
      xmlDoc.send("");
      return xmlDoc.responseXML;
      }
    // IE
    else if (ActiveXObject("Microsoft.XMLDOM"))
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.load(dname);
      return xmlDoc;
      }
    alert("Error loading document");
    return null;
    } 
    
    function display(id){
    
    xmlDoc=loadXMLDoc("xmlfile.xml");
    x=xmlDoc.getElementsByTagName("LISTING")
    for(i=0;i<x.length;i++)
    {
    //document.write(x.item(i).attributes[0].textContent);
    //document.write("<br />");
    if(x.item(i).attributes[0].textContent==id){
    
    document.getElementById('name').innerHTML=x.item(i).childNodes[1].childNodes[0].nodeValue;
    document.getElementById('author').innerHTML=x.item(i).childNodes[3].childNodes[0].nodeValue;
    document.getElementById('price').innerHTML=x.item(i).childNodes[5].childNodes[0].nodeValue;
    document.getElementById('publisher').innerHTML=x.item(i).childNodes[7].childNodes[0].nodeValue;
    document.getElementById('img').src=x.item(i).childNodes[9].childNodes[0].nodeValue;
    
    }
    } 
    	
    }

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess you are talking about IE6, because IE7/8 will properly interpret XMLHttpRequest()....

    Looking at your else if (ActiveXObject("Microsoft.XMLDOM"))
    statement, there seems to be missing open, send, responseXML. Also you have not explicitely set the MIME type to text/xml


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •