Here’s all the details from the E4X spec: Expressions may be used to compute parts of an XML initialiser. Expressions are delimited by curly braces and may appear inside tags or element content. Inside a tag, expressions may be used to compute a tag name, attribute name, or attribute value. Inside an element, expressions may be used to compute element content. For example, for (var i = 0; i < 10; i++) e[i] = <employee id={i}> // compute id value <name>{names[i].toUpperCase()}</name> // compute name value <age>{ages[i]}</age> // compute age value </employee>; Each expression is evaluated and replaced by its value prior to parsing the literal XML value. For example the following expression, var tagname = "name"; var attributename = "id"; var attributevalue = 5; var content = "Fred"; var x = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>; would assign the following XML value to the variable x. <name id="5">Fred</name>
I’m pretty sure that the only place a curly brace literal is legal is in a CDATA block. On Jan 4, 2016, at 7:27 PM, Alex Harui <aha...@adobe.com> wrote: > > > On 1/4/16, 8:17 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> For literals, yes, we’d for the most part just pass the whole thing as a >> string to the constructor. The only exception I can think of is bracket >> notation: >> >> var foo:XML = <node><subnode attr={myAttr}>foo</subnode></node>; >> would have to become: >> var foo:XML = new XML('<node><subnode >> attr="‘+myAttr+’">foo</subnode></node>’); > > Wow, didn't know about that capability. I'll have to see what the parser > knows about that. > > -Alex >