
XML.childNodes Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
922
|
ActionScript Language Reference
If the XML element represented by theNode has no attributes, attributes is an empty object
with no properties, and the preceding example would indicate zero attributes.
See Also
XML.nodeType
XML.childNodes Property
an array of references to a node’s children
Flash 5
read-only
theNode.childNodes[n]
Description
The childNodes property is an array whose elements contain references to the immediate
descendants of
theNode, where theNode can be an XML or XMLnode instance. The
childNodes property is used to access nodes in an XML hierarchy. For example, if we create
an object hierarchy as follows:
myDoc = new XML('<STUDENT><NAME>Tim</NAME><MAJOR>BIOLOGY</MAJOR></STUDENT>');
we can then access the STUDENT node using:
myDoc.childNodes[0];
We can access the NAME and MAJOR nodes (which are descendants of STUDENT) using:
myDoc.childNodes[0].childNodes[0]; // NAME
myDoc.childNodes[0].childNodes[1]; // MAJOR
If the hierarchy below theNode changes, childNodes is automatically updated to reflect the
new structure. For example, if we delete the
MAJOR node, myDoc.childNodes[0].
childNodes[1]
will return undefined.
We often refer to nodes to manipulate information or rearrange a document’s structure.
For example, we can change a student’s name or add a new ...