XMLNode
1317
trace ("doc2: " + doc2); // output: doc2: <root />
// create a new node to append to root node (named clone) of doc1
var newNode:XMLNode = doc1.createElement("newbie");
clone.appendChild(newNode);
trace ("doc1: " + doc1); // output: doc1: <root><newbie /></root>
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
Example
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
childNodes (XMLNode.childNodes property)
public childNodes : Array [read-only]
An array of the specified XML object's children. Each element in the array is a reference to an
XML object that represents a child node. This is a read-only property and cannot be used to
manipulate child nodes. Use the
appendChild()
,
insertBefore()
, and
removeNode()
methods to manipulate child nodes.
This property is undefined for text nodes (
nodeType == 3
).
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...