문제

Having this code

var images:XML = 
    <elements>
        <el data-custom="abc"/>
        <el data-custom="def"/>
        <el data-custom="ghi"/>
    </elements>

How can i get attributes value with an e4x expression? Please note the dash "-" character in the attribute name. I use it in Flex but it could be a general question for the E4X standard.

You can't obviously use:

 trace(elements.el.@data-custom)
도움이 되었습니까?

해결책 2

After some not so easy search I found an answer for the posterity

elements.el.@['data-custom'];

다른 팁

In numerous occasions I prefer using the attribute() method of XML/XMLList instead of the (@) identifier. It also works with the attribute names that are also reserved Actionscript words like "class","package", "return",etc...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top