Comunidad de diseño web y desarrollo en internet online

Problema con lectura XML

Citar            
MensajeEscrito el 05 Mar 2009 12:28 pm
Hola a todos de nuevo!

Sigo con mi galería en XML pero me ha surgido un problemilla.
Ahora mismo estoy mostrando en pantalla sólo 4 imágenes de las cuales 2 de ellas se repiten y no se por qué...

Les explico el XML:

<galeria nombre="Galería1">
<foto1>foto4.jpg</foto1>
<foto2>foto2.jpg</foto2>
<foto3>foto3.jpg</foto3>
<foto4>foto1.jpg</foto4>
</galeria>

En el flash lo leo asi:

function cargarDatos(_indice:Number){

var nombre:String;
var foto1:String;
var foto2:String;
var foto3:String;
var foto4:String;

nombre = noticias_xml.firstChild.childNodes[_indice].attributes.nombre;
foto1 = noticias_xml.firstChild.childNodes[_indice].firstChild.firstChild.nodeValue;
foto2 = noticias_xml.firstChild.childNodes[_indice].firstChild.nextSibling.firstChild.nodeValue;
foto3 = noticias_xml.firstChild.childNodes[_indice].firstChild.nextSibling.firstChild.nodeValue;
foto4 = noticias_xml.firstChild.childNodes[_indice].lastChild.firstChild.nodeValue;

}

Entonces me muestra la misma imagen en "Foto2" y "Foto3".

¿Que estoy haciendo mal?

Por cotk

61 de clabLevel



 

safari
Citar            
MensajeEscrito el 05 Mar 2009 12:54 pm
Claro, lo que estas haciendo es asignar el mismo nodo a los dos valores...
Tendrias que hacerlo asi:

Código :

foto1 = noticias_xml.firstChild.childNodes[_indice].childNodes[0].firstChild.nodeValue;
foto2 = noticias_xml.firstChild.childNodes[_indice].childNodes[1].firstChild.nodeValue;
foto3 = noticias_xml.firstChild.childNodes[_indice].childNodes[2].firstChild.nodeValue;
foto4 = noticias_xml.firstChild.childNodes[_indice].childNodes[3].firstChild.nodeValue;

Por Zguillez

BOFH

10744 de clabLevel

85 tutoriales
17 articulos
3 ejemplos

Genero:Masculino   Bastard Operators From Hell Héroes Team Cristalab Editores

BCN

clabbrowser
Citar            
MensajeEscrito el 05 Mar 2009 01:30 pm
YEAH!!! Funcionó!

Ahora todo va perfecto. Justo lo que quería.

Muchas gracias!! :wink:

Por cotk

61 de clabLevel



 

safari

 

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