Referencing ActionScript Reserved Words in E4X

If you have a chunk of XML with reserved ActionScript words in it, you won’t be able to use E4X syntax like you’re used to. For instance, say you need to parse the following XML:

var codeXML:XML =
<code>
<class name="Order">
<function name="getId">
<access>public</access>
<return>Number</return>
</function>
</class>
</code>;

Since this XML is full of reserved words, you won’t be able to access nodes like this:

trace(codeXML.class.function.return);

Instead, use bracket syntax like this:

trace(codeXML["class"].@name);
trace(codeXML["class"]["function"].access);
trace(codeXML["class"]["function"]["return"]);