Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 321

Programming actionscript 3.0
Table of Contents

Advertisement

As the following example shows, you can also use curly brace operators (
by reference (from other variables) when constructing XML objects:
var ids:Array = [121, 122, 123];
var names:Array = [["Murphy","Pat"], ["Thibaut","Jean"], ["Smith","Vijay"]]
var x:XML = new XML("<employeeList></employeeList>");
for (var i:int = 0; i < 3; i++)
{
var newnode:XML = new XML();
newnode =
<employee id={ids[i]}>
<last>{names[i][0]}</last>
<first>{names[i][1]}</first>
</employee>;
x = x.appendChild(newnode)
}
You can assign properties and attributes to an XML object by using the
following:
var x:XML =
<employee>
<lastname>Smith</lastname>
</employee>
x.firstname = "Jean";
x.@id = "239";
This sets the XML object
<employee id="239">
<lastname>Smith</lastname>
<firstname>Jean</firstname>
</employee>
You can use the + and += operators to concatenate XMLList objects:
var x1:XML = <a>test1</a>
var x2:XML = <b>test2</b>
var xList:XMLList = x1 + x2;
xList += <c>test3</c>
This sets the XMLList object
<a>test1</a>
<b>test2</b>
<c>test3</c>
to the following:
x
to the following:
xList
Assembling and transforming XML objects
and
) to pass data
{
}
operator, as in the
=
321

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents