counting the number of nodes is not working

gameksh

New Member
I have an xml file :\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><food> <cuisine type="Chinese"> <restaurant name = "Panda Express"> <location id= "0"></location> <phone id = "1"></phone> <city id="2"></phone> </restaurant> <restaurant name = "Mr. Chau's"> </restaurant> </cuisine> <cuisine type="Indian"> <restaurant name = "Shan"> </restaurant> </cuisine></food>\[/code\]and I am trying to count the number of cuisine nodes this is the code I have, I know its mostly right but when I try to print out the length of the nodelist it says it's 0\[code\]//starts talking to the xml document if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); }else{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","data.xml", false); xmlhttp.send(); xmlData = http://stackoverflow.com/questions/11373062/xmlhttp.responseXML; //fills the first comboBox var sel = document.getElementById('CuisineList'); cuisineList = xmlData.getElementsByTagName('cuisine'); document.getElementById("test").innerHTML = cuisineList.length;\[/code\]
 
Back
Top