I am trying to get the value of an attribute full
where another attribute name
is equal to something e.target.name
.
我试图获取一个属性的值,其中另一个属性名称等于e.target.name。
So in this case I am trying to get the value of "full"
所以在这种情况下,我试图获得“完整”的价值
var full_url = myXML.item.@full.(@name=="e.target.name");
This is my XML:
这是我的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 my as above should return one of the But when I trace full_url I get nothing and no errors.
所以我上面应该返回其中一个但是当我追踪full_url时,我什么也没得到,没有错误。
1 个解决方案
#1
4
You have two errors in your e4x statement: There should not be quotes around e.target.name
, and you have to select the item before you can call the value of @full
.
您的e4x语句中有两个错误:e.target.name周围不应该有引号,您必须先选择该项,然后才能调用@full的值。
This should work:
这应该工作:
var full_url:String = myXML.item.(@name==e.target.name).@full;
(that's assuming myXML
also has a root element somewhere).
(假设myXML在某处也有一个根元素)。
#1
4
You have two errors in your e4x statement: There should not be quotes around e.target.name
, and you have to select the item before you can call the value of @full
.
您的e4x语句中有两个错误:e.target.name周围不应该有引号,您必须先选择该项,然后才能调用@full的值。
This should work:
这应该工作:
var full_url:String = myXML.item.(@name==e.target.name).@full;
(that's assuming myXML
also has a root element somewhere).
(假设myXML在某处也有一个根元素)。