I have an XML file:
<items> <item>An item.</item> <item>Another item.</item> </items>
And this script:
function readXML() { // code for IE if (window.ActiveXObject) { alert ('IE') var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xmlDoc.load("xmlfile.xml"); } // code for Mozilla, etc. else if (document.implementation && document.implementation.createDocument) { alert ('FF') var xmlDoc = document.implementation.createDocument("", "", null); xmlDoc.async = false; xmlDoc.load("xmlfile.xml"); } else { alert('Your browser cannot handle this script'); } var items = xmlDoc.getElementsByTagName('item'); for (i=0; i < items.length; i++) { itemsarray[i] = items[i].firstChild.nodeValue; alert(itemsarray[i]); } } readXML();
What am I doing wrong?
See if you can find a XML to JSOn script.
Ack, this AJAX shit is over my head
Just trying to get a basic XML file into a JS array..
Will look up some more AJAX tuts I guess.