Frage

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)
War es hilfreich?

Lösung 2

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

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

Andere Tipps

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...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top