Search code examples
javascriptxmlapache-flexactionscripte4x

How I can use EX4 with an attribute containing dash character?


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)

Solution

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

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