With bracket notation I can access a direct child node by name or attribute using the following code:
Example XML:
<item name="item1">
<categories name="catList">
<category name="cat1">
</categories>
</item>
Example accessing direct child node:
trace(xml["categories"].toString()); // <categories><category/></categories>
Example accessing node attribute:
trace(xml["@name"].toString()); // item1
Updated: Is there a way to access a subelement / nested element / nested attribute using only a single square bracket notation?
For example,
trace(xml["categories.category.@name"].toString()); // cat1
or
trace(xml["categories.@name"]); // catList
Using the square bracket notation is unnecessary if you know the names of the nodes you’re accessing. This should work fine:
Square bracket notation is used to access properties with a string name. It is not specifically related to E4X. The translation of all properties to square bracket notation would be this: