ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > XMLNode > attributes (XMLNode.attributes property) | |||
public attributes : Object
An object containing all of the attributes of the specified XML instance. The XML.attributes object contains one variable for each attribute of the XML instance. Because these variables are defined as part of the object, they are generally referred to as properties of the object. The value of each attribute is stored in the corresponding property as a string. For example, if you have an attribute named color, you would retrieve that attribute's value by specifying color as the property name, as the following code shows:
var myColor:String = doc.firstChild.attributes.color;
Availability: ActionScript 1.0; Flash Player 5
The following example shows how to read and write the attributes of an XML node:
var doc:XML = new XML("<mytag name='Val'> item </mytag>");
trace(doc.firstChild.attributes.name); // Val
doc.firstChild.attributes.order = "first";
trace (doc.firstChild); // <mytag order="first" name="Val"> item </mytag>
for (attr in doc.firstChild.attributes) {
trace (attr + " = " + doc.firstChild.attributes[attr]);
}
// order = first
// name = Val
|
|
|
|