Given that x.length is whatever number (let's say 20), then why does this:
print the list of all 20 cities, but this:
displays only the last one in the list?
Thanks in advance?
Code:
<script type="text/javascript"> xmlDoc = loadXMLDoc("stations.xml"); x = xmlDoc.getElementsByTagName('city'); for (i=0;i<x.length;i++) { if (x[i].parentNode.parentNode.getAttribute('id2')=='TX') { document.write(x[i].childNodes[0].nodeValue + "<br />"); } } </script>
Code:
<script type="text/javascript"> xmlDoc = loadXMLDoc("stations.xml"); x = xmlDoc.getElementsByTagName('city'); for (i=0; i<x.length; i++) { if (x[i].parentNode.parentNode.getAttribute('id2')=='TX') { document.getElementById("cityList").innerHTML = x[i].childNodes[0].nodeValue + "<br />"; } } </script>
Thanks in advance?
Comment