Foros del Web » Creando para Internet » Flash y Actionscript »

Cargar xml en Flash

Estas en el tema de Cargar xml en Flash en el foro de Flash y Actionscript en Foros del Web. Hola necesito cargar una linea concreta de un archivo xml (rss) en un campo dinámico de flash. El archivo xml "news.xml" tiene esta estructura: <?xml-stylesheet ...
  #1 (permalink)  
Antiguo 06/12/2007, 10:44
 
Fecha de Ingreso: diciembre-2007
Mensajes: 22
Antigüedad: 16 años, 4 meses
Puntos: 0
Cargar xml en Flash

Hola necesito cargar una linea concreta de un archivo xml (rss) en un campo dinámico de flash.

El archivo xml "news.xml" tiene esta estructura:

<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="rss_convert.xsl"?>
<rss version="0.91">
<channel>
<title>RTÉ News</title>
<link>http://www.rte.ie/rss/news.xml</link>
<description>Latest Irish and international news supplied by RTE.ie</description>
<copyright>Copyright © RTÉ Publishing</copyright>

<pubDate>Wed, 05 Dec 2007 16:49:48 +0000</pubDate>
<lastBuildDate>Wed, 05 Dec 2007 16:49:48 +0000</lastBuildDate>
<category domain="News">General News</category>
<image>
<url>http://www.rte.ie/images/logo.gif</url>
<link>http://www.rte.ie</link>

</image>
<item>
<title>Cowen delivers fourth Budget</title>
<description>Minister for Finance Brian Cowen has delivered his fourth Budget against what he has described as a challenging economic backdrop.</description>
<pubDate>Wed, 05 Dec 2007 16:49:42 +0000</pubDate>
<createDate>Wed, 05 Dec 2007 00:00:00 +0000</createDate>
<link>http://www.rte.ie/news/2007/1205/budget.html?rss</link>

</item>
</channel>
</rss>


El archivo flash tiene un campo de texto dinamico llamado "item_1_txt" y el siguiente codigo:



var cargaxml:XML = new XML();


cargaxml.onLoad = function(exito) {
if (exito) {


item_1_txt.text = cargaxml.firstChild.childNodes[0].childNodes[0].childNodes[0]





} else {
trace("error al cargar el archivo");
}
};


cargaxml.ignoreWhite = true;
cargaxml.load("news.xml");


Este código me carga la siguiente etiqueta: <title>RTÉ News</title>... pero yo necesito cargar el titular de la primera noticia: <title>Cowen delivers fourth Budget</title>.

Si alguien me puede ayudar lo agradecería muchísimo.

Muchas gracias.
  #2 (permalink)  
Antiguo 06/12/2007, 14:42
Avatar de SinguerInc  
Fecha de Ingreso: octubre-2007
Ubicación: Barcelona, España
Mensajes: 551
Antigüedad: 16 años, 6 meses
Puntos: 5
Re: Cargar xml en Flash

horas y horas he pasado con aquellos xmls malditos. ya no mas.
yeah! is here:

Código:
var cargaxml:XML = new XML();
cargaxml.onLoad = function(exito) {
if (exito) {
item_1_txt.text = cargaxml.firstChild.childNodes[0].childNodes[8].childNodes[0];
} else {
trace("error al cargar el archivo");
}
};
cargaxml.ignoreWhite = true;
cargaxml.load("news.xml");
saludos...esto es prehistorico, prueba con Actionscript 3...seria:

cargaxml.channel.item.title

solo eso...un poco mas facil no?

Estoy desarrollando un nuevo juego "PanQueso", te gustaria verlo?, link en mi firma. Comentarios? a veces falla en Firefox...
__________________
/blog.singuerinc.com
  #3 (permalink)  
Antiguo 08/12/2007, 19:01
 
Fecha de Ingreso: diciembre-2007
Mensajes: 22
Antigüedad: 16 años, 4 meses
Puntos: 0
Sonrisa Re: Cargar xml en Flash

Muchas gracias por tu respuesta.

El codigo "cargaxml.firstChild.childNodes[0].childNodes[8].childNodes[0].childNodes[0]" me ha funcionado correctamente,

pero me parece interesante lo facil que parece hacer esto con AS3.

No se si he hecho correctamente el ejemplo que me has dado... he sustituido la linea anterior por "cargaxml.channel.item.title" y no me funciona.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 04:07.