urlXML = new XML(); urlXML.onLoad = convertXML; content_feed_display = "Cargando datos XML..."; urlXML.load("moreover_cybercultura.xml"); function convertXML() { if(this.loaded) { content_feed_display = "Datos cargados."; } mainTag = new XML; elementTag = new XML; articleList = new Array; elementList = new Array; //first get a handle on the first actual element in the document. //note we skip to the nextSibling element, since the first element //is a document definition tag. mainTag = this.firstChild.nextSibling; //make sure we have the right parent tag. Do this by looking at the nodeName property //for this object. This will correspond exactly to the , where nodeName is replaced //with the name of your xml tag if(mainTag.nodeName.toLowerCase() == "moreovernews") { //if we have a match, we collect all of the articles beneath it as an array of xml objects articleList = mainTag.childNodes; //now we loop over all the articles and look for the tags we are looking for... content_feed_display = ""; for(i=0;i<=articleList.length;i++){ //initialize a couple of variables to hold xml data we want displayed document_url = ""; headline_text = ""; source_text = ""; if(articleList[i].nodeName.toLowerCase() == "article") { //we get the child node array beneath the articles, aka the meat and potatoes we are after elementList = articleList[i].childNodes; //and loop through that looking for the data we need for(j=0;j<=elementList.length;j++) { elementTag = elementList[j]; elementType = elementTag.nodeName.toLowerCase(); if(elementType == "headline_text"){ headline_text = elementTag.firstChild.nodeValue; } else { if(elementType == "url"){ url = elementTag.firstChild.nodeValue; } else { if(elementType == "source"){ source_text = elementTag.firstChild.nodeValue; } } } } content_feed_display += "

"+ headline_text +"
Fuente: " + source_text + "

"; } } } }