Ad esempio:
codice:mio_xml = new XML(); mio_xml.path = this; mio_xml.ignoreWhite = true; mio_xml.onLoad = function(success) { if (success) { this.path.newspaper = new Object(); var o = this.path.newspaper; o._info = {titolo:this.firstChild.attributes.titolo, data:this.firstChild.attributes.data}; o._sezioni = []; var nodes = this.firstChild.childNodes; for (var i = 0; i < nodes.length; i++) { var nome = nodes[i].attributes.nome; o._sezioni.push(nome); var children = nodes[i].childNodes; o[nome] = {_articoli:children.length}; for(var j = 0; j < children.length; j++){ o[nome]["articolo_" + j] = {}; var grandchildren = children[j].childNodes; for(var k = 0; k < grandchildren.length; k++){ o[nome]["articolo_" + j][grandchildren[k].nodeName] = grandchildren[k].firstChild.nodeValue; } } } } else { trace("Caricamento Errato!"); } }; mio_xml.load("./eNewspaper.xml");

Rispondi quotando