Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load XML in Mozilla

Status
Not open for further replies.

QuantumDoja

Programmer
Jun 11, 2004
76
GB
Hi, I have some code that is supposed to load some xml in either IE or mozilla and count how many categories there are from an xml file, it works fine in IE, but in mozilla it returns zero. any ideas?

Code:
<script language="JavaScript">

var xmlDoc; 
function importXML(file) { 
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined'); 
var ie = (typeof window.ActiveXObject != 'undefined'); 

if (moz) { 
  xmlDoc=document.implementation.createDocument("", "", null);
  xmlDoc.async = false; 
  } else if (ie) { 
   xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
   xmlDoc.async = false; 
   while(xmlDoc.readyState != 4) {}; 
  } 
xmlDoc.load(file); 
} 


importXML("StarterXML.asp");

Category = xmlDoc.getElementsByTagName("CATEGORY");
alert(Category.length);


</script>

my example xml

Code:
 <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <ROOT>
+ <CATEGORY>
+ <CATEGORY>
+ <CATEGORY>
- <CATEGORY>
  <ID>103</ID>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top