Adobe Flex 3 Help

Binding data into an XML data model

Flex compiles the <mx:XML> tag into literal XML data in an ActionScript xml.XMLNode or XML object. This is different from the <mx:Model> tag, which Flex compiles into an Action object that contains a tree of ActionScript objects. To bind data into an <mx:XML> data model, you can use the curly braces syntax the same way you do with other data models. However, you cannot use a node within the data model as a binding source.

Adobe does not recommend using the <mx:Binding> tag for this type of binding because doing so requires you to write an appropriate ActionScript XML command as the destination property of the <mx:Binding> tag. For more information about the <mx:XML> tag, see Defining a data model.

The following example shows an <mx:XML> data model with binding destinations in curly braces:

<?xml version="1.0"?>
<!-- Models\XMLBinding.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:XML id="myEmployee" format="e4x">
        <employee>
            <name>
                <first>{firstName.text}</first>
                <last>{lastName.text}</last>
                </name>
            <department>{department.text}</department>
            <email>{email.text}</email>
        </employee>
    </mx:XML>
    <mx:TextInput id="firstName"/>
    <mx:TextInput id="lastName"/>
    <mx:TextInput id="department"/>
    <mx:TextInput id="email"/>
</mx:Application>