Get attribute value from XML using as3

I am trying to get the value of the full attribute, where the other name attribute is equal to something e.target.name .

So in this case, I am trying to get the value "full"

 var full_url = myXML.item.@full. (@name=="e.target.name"); 

This is my XML:

 <item name="Toy Box" thumb="resize/thumb_image2.png" full="full_images/image2.png" /> <item name="Toy Train" thumb="resize/thumb_image3.png" full="full_images/image3.png" / > <item name="Toy Truck" thumb="resize/thumb_image4.png" full="full_images/image4.png" /> 

So mine, as above, must return one of them. But when I spend full_url, I get nothing and no errors.

+4
source share
1 answer

You have two errors in your e4x clause: there should not be quotes around e.target.name , and you need to select the item before you can call the @full value.

This should work:

 var full_url:String = myXML.item.(@name==e.target.name) .@full ; 

(assuming myXML also has a root element).

+4
source

Source: https://habr.com/ru/post/1392269/


All Articles