Comunidad de diseño web y desarrollo en internet online

Problemilla accediendo a XML por los atributos

Citar            
MensajeEscrito el 27 Jun 2008 08:56 am
hola!!

Tengo un XML tal cual:

<datos name="meses">
<item type="invierno" content="enero" />
</datos>


y he intentado sin éxito acceder a "content" de las siguientes maneras:

Código :

xml = new XML(e.target.data);
var  eldato:XMLList  =  xml.dataset.item.(@type  ==  "invierno").content;


Código :

xml = new XML(e.target.data);
var  eldato:XMLList  =  xml.dataset.(@name  ==  "meses").item.(@type  ==  "invierno").content;


Alguna sugerencia??

Por PrincesaLeya

39 de clabLevel



Genero:Femenino  

firefox
Citar            
MensajeEscrito el 27 Jun 2008 09:22 am
A los atributos de un XML se accede con @ delante como mismo hiciste con @type, en el caso del XML que pones si es así completo no tines que poner el nodo madre y lo que obtienes cuando accedes a un atributo es un String. Por ejemplo el XML que pones de ejemplo ha sido leido dentro de la variable myXML, si quisiera acceder a @content del item que tiene @type igual a invierno la sintaxis correcta sería:

Código :

var eldato:String =  myXML.item.(@type  ==  "invierno")[email protected]();

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 27 Jun 2008 10:42 am
Gracias, ya funciona !

Por PrincesaLeya

39 de clabLevel



Genero:Femenino  

firefox
Citar            
MensajeEscrito el 27 Jun 2008 02:37 pm
tambien podes acceder con

Código :

myXML.attribute("name");


yo por lo menos accedo así cuando cargo xml externos.

Por phoxer

Claber

827 de clabLevel

4 tutoriales

Genero:Masculino  

Ing en Sistemas

firefox

 

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