 
			
				28/05/2008, 07:11
			
			
			     |  
      |    |    |    Fecha de Ingreso: marzo-2005  
						Mensajes: 1.418
					  Antigüedad: 20 años, 7 meses Puntos: 9     |        |  
  |      Problemones con XML en AS3        Hola. Estoy intentando cargar un archivo xml externo e ir leyendo algunas cosas de el, pero realmente me está frustrando. Probé mil formas distintas, y siempre con resultados no deseados. Encontré un código en la red, que es el que voy a postear acá, y tampoco me funciona de la manera correcta. El archivo xml de prueba es:   
<?xml version="1.0" encode="UTF-8"?> 
<!DOCTYPE data[ 
<!ELEMENT title(comments, image)> 
<!ATTLIST title name CDATA #REQUIRED> 
<!ELEMENT comments (#PCDATA)> 
<!ELEMENT image (#PCDATA)> 
]> 
<data> 
<title name="Anastasio"> 
<comments>This is a nice guy</comments> 
<image>an2.jpg</image> 
</title> 
<title name="Anastasio's car"> 
<comments>Anastasio loves his car</comments> 
<image>an1.jpg</image> 
</title> 
</data>     
Como verán es bastante siemple. Ahora, en mi película flash, tengo el siguiente código:   
var loader:URLLoader = new URLLoader(); 
loader.dataFormat = URLLoaderDataFormat.TEXT; 
loader.addEventListener(Event.COMPLETE, onLoadXML); 
loader.load(new URLRequest("anastasio.xml"));   
function onLoadXML(ev:Event){ 
   try{ 
        //Convert the downloaded text into an XML 
        var myXML:XML = new XML(ev.target.data);  trace(myXML); 
        var list:XMLList = myXML.data.title;  trace(list.length()); 
        //walks the list and show in textfields 
        for(var i=0; i<list.length(); i++){ 
            //trace(list[i].@name+"-"+list[i].comments+" - "+list[i].image) 
            trace(list[i].@name);        
        } 
    } catch (e:TypeError){ 
        //Could not convert the data, probavlu because 
        //because is not formated correctly 
        trace("Could not parse the XML"); 
        trace(e.message); 
    } 
}   
El primer trace me arroja todo el documento xml de manera correcta. Es decir, que los datos del xml son bien cargados. El segundo trace me arroja siempre 0, a pesar de que haya dos nodos title. ¿Alguien se da una idea de que está sucediendo?     
				__________________  Add, never Remove             |