XML:
Código :
<DOCUMENTO> <LIBRO ID="0001"> <TITULO>El Hobbit</TITULO> <AUTOR>J.R.R. Tolkien</AUTOR> <EDITORIAL>Anaya</EDITORIAL> <WEB URL="http://www.elhobbit.com">elhobbit.com</WEB> </LIBRO> <LIBRO ID="0002"> <TITULO>La Fundacion</TITULO> <AUTOR>Isaac Asimov</AUTOR> <EDITORIAL>RBA</EDITORIAL> <WEB URL="http://www.thefoundation.com">thefoundation.com</WEB> </LIBRO> <LIBRO ID="0003"> <TITULO>El Caballo de Troya</TITULO> <AUTOR>J.J. Benitez</AUTOR> <EDITORIAL>CIFI</EDITORIAL> <WEB URL="http://www.elcaballodetroya.com">elcaballodetroya.com</WEB> </LIBRO> <LIBRO ID="0004"> <TITULO>1984</TITULO> <AUTOR>George Orwell</AUTOR> <EDITORIAL>Raven</EDITORIAL> <WEB URL="http://www.georgeorwell.com">georgeorwell.com</WEB> </LIBRO> </DOCUMENTO>
ACTION EN FLASH:
Código :
miXML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(leido) {
if (leido) {
i = 0;
testXML();
} else {
trace("No se puede leer el XML");
}
};
miXML.load("libros.xml");
function testXML() {
documento = miXML.firstChild;
libro = miXML.firstChild.childNodes[i];
ref_txt = libro.attributes.ID;
tit_txt = libro.childNodes[0].firstChild;
aut_txt = libro.childNodes[1].firstChild;
edi_txt = libro.childNodes[2].firstChild;
url_txt = "<a href=\""+libro.childNodes[3].attributes.URL+"\" target=\"_blank\">"+libro.childNodes[3].firstChild+"</href>";
}
primens.onPress = function() {
i = 0;
testXML();
};
ultim.onPress = function() {
i = documento.childNodes.length-1;
testXML();
};
libroadelante.onPress = function() {
if (i<documento.childNodes.length-1) {
i++;
} else {
i = 0;
}
testXML();
};
libroatras.onPress = function() {
if (i>0) {
i--;
} else {
i = documento.childNodes.length-1;
}
testXML();
};
[/code] 