User Guide
XML class 173
XML.attributes
Availability
Flash Media Server 2.
Usage
my_xml.attributes
Description
Property; an object that contains all the attributes of the specified XML object. Associative
arrays use keys as indexes, not ordinal integer indexes used by regular arrays. In the
XML.attributes associative array, the key index is a string representing the name of the
attribute. The value associated with that key index is the string value associated with that
attribute. For example, if you have an attribute named
color, you would retrieve that
attribute’s value by using the color as the key index, as shown in the following code:
var myColor = doc.firstChild.attributes.color
Example
The following example shows the XML attribute names:
// Create a tag called 'mytag' with
// an attribute called 'name' with value 'Val'.
var doc = new XML("<mytag name=\"Val\"> item </mytag>");
// Assign the value of the 'name' attribute to variable y.
var y = doc.firstChild.attributes.name;
trace (y); // output: Val
// Create a new attribute named 'order' with value 'first'.
doc.firstChild.attributes.order = "first";
// Assign the value of the 'order' attribute to variable z.
var z = doc.firstChild.attributes.order
trace(z); // output: first
NOTE
In Flash Media Server, the output of trace() statements appears in the application log
file and Application inspector.