Comunidad de diseño web y desarrollo en internet online

Nombrar el ultimo termino de un XML

Citar            
MensajeEscrito el 22 Jul 2008 12:17 pm
Hola a todos, tengo una pequeña duda que no se como resolver, el caso es que tengo un xml de este tipo

<menu>
<boton url="01.jpg">1</boton>
<boton url="02.jpg">2</boton>
<boton url="03.jpg">3</boton>
<boton url="04.jpg">4</boton>
<boton url="05.jpg">5</boton>
<boton url="06.jpg">6</boton>
<boton url="02.jpg">7</boton>
<boton url="03.jpg">8</boton>
<boton url="04.jpg">9</boton>
<boton url="05.jpg">10</boton>
<boton url="06.jpg">11</boton>
<boton url="Titulo">Informacion del titulo en general tipo parrrafo</boton>
</menu>

y tengo en flash lo siguiente

titulo.text=foto(foto.length).firstChild.nodeValue;

y da undefined por lo que no se me ocurre otra cosa, alguna ayuda?

gracias

Por yosmaller

3 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 22 Jul 2008 02:21 pm
Porque el primer nodo del XML es 0 no 1 por lo tanto el ultimo debe ser length-1. Ya que un XML de 10 elementos, el último es el 9

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 22 Jul 2008 02:30 pm
Además la sintaxis correcta es:

Código :

var total:Number = foto.firstChild.childNodes.length;
titulo.text=foto.firstChild.childNodes[total - 1].firstChild.nodeValue;

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.