Jump to content

Ie8 Vs Xml


divyac

Recommended Posts

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:

function loadXMLDoc(dname){var xmlDoc;if (window.XMLHttpRequest)  {  xmlDoc=new window.XMLHttpRequest();  xmlDoc.open("GET",dname,false);  xmlDoc.send("");  return xmlDoc.responseXML;  }// IEelse 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;}} 	}

Link to comment
Share on other sites

The page you're linking to doesn't appear to work at all. That is, it has no output (no source!) whatsoever.Does xmlfile.xml contain an element like <LISTING>, or is it <listing>? If the latter, the problem could be that Firefox reads the XML file as HTML, and is therefore case insensitive. XML is case sensitive, so if that's the case - it's IE that's behaving correctly by not matching anything.

Link to comment
Share on other sites

OK, the page now appeared. As I thought, the problem is the XML, though not case sensitivity.You have a DTD in your XML, and your XML doesn't validate against it. Either specify a DTD URL against which the XML validates, or (better yet), remove the DTD. You could also disable the "validateOnParse" option, but that's needless in this case.

Link to comment
Share on other sites

Odd... well, just to make sure it's still not a validation issue, add

xmlDoc.validateOnParse = false;

Right after

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;

in the loadXMLDoc() function.[edit]Wait, I just remembered something. Firefox reads spaces, and IE doesn't. Either use means other than "childNodes", or loop over the "childNodes" and find the nodes you need. Alternatively (and this is what I prefer to do), remove all whitespace from your XML document, then adjust your childNodes numbers accordingly.[/edit]

Link to comment
Share on other sites

Try to remove the whitespace in your XML document, then adjust your childNodes accordingly.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...