Comunidad de diseño web y desarrollo en internet online

Gestor de noticias Flash + XML

Citar            
MensajeEscrito el 28 Nov 2005 10:56 am
Hola, necesito ayuda para obtener la información de un fichero XML, y presentarlo en un swf de flash. Tengo el siguiente archivo XML:
...........................................................
<?xml version="1.0" encoding='iso-8859-1'?>
<raiz>
<seccion nombre="internacional" id="1">
<noticia id="1" titulo="titulo de la noticia" noticia="cuerpo de la noticia" fecha_publicacion="xx-xx-xxxx"/>
ETC ...
</seccion>
<seccion nombre="nacional" id="2">
<noticia id="1" titulo="titulo de la noticia" noticia="cuerpo de la noticia" fecha_publicacion="xx-xx-xxxx"/>
ETC ...
</seccion>
ETC ...
</raiz>
...........................................................
Con el siguiente codigo cargo el fichero XML:

var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.load("fichero.xml");

my_xml.onLoad = function(exito) {
if (exito) {
}
else {
trace("Error, no se pudo cargar el fichero XML");
}
}

El problema se presenta al recorrer el XML, tras muchas vueltas lo maximo que he consegui es mediante:
output // <noticia id="1" titulo="titulo de la noticia" noticia="cuerpo de la noticia" fecha_publicacion="xx-xx-xxxx"/>

pero no cosigo sacar por separado los nodos id, titulo, noticia, fecha_publicacion.
Un saludo, gracias.

Por davalas

2 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 28 Nov 2005 11:11 am
Hola davalas, bienvenido al foro. Como suelen decir los moderadores "te aconsejo que leas las reglas antes de postear, y el manual para preguntar :)", ya te informaran ellos...

Para acceder a los "nodos" que tu dices, que en realidad son atributos necesitaras esto:
my_xml.firstChild.firstChild.childNodes[1].atributes.id;
my_xml.firstChild.firstChild.childNodes[1].atributes.titulo;
my_xml.firstChild.firstChild.childNodes[1].atributes.noticia;
my_xml.firstChild.firstChild.childNodes[1].atributes.fecha_publicacion;

my_xml.firstChild.firstChild.childNodes[2].atributes.id;
my_xml.firstChild.firstChild.childNodes[2].atributes.titulo;
my_xml.firstChild.firstChild.childNodes[2].atributes.noticia;
my_xml.firstChild.firstChild.childNodes[2].atributes.fecha_publicacion;

etc etc

Por frenadoll

922 de clabLevel

6 tutoriales

Genero:Masculino  

Barcelona

firefox

 

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