User Guide

748 ActionScript classes
Parameters
newChild:XMLNode - The XMLNode object to be inserted.
insertPoint:XMLNode - The XMLNode object that will follow the newChild node after the
method is invoked.
Example
The following inserts a new XML node between two existing nodes:
var my_xml:XML = new XML("<a>1</a>\n<c>3</c>");
var insertPoint:XMLNode = my_xml.lastChild;
var newNode:XML = new XML("<b>2</b>\n");
my_xml.insertBefore(newNode, insertPoint);
trace(my_xml);
See also
XML, cloneNode (XMLNode.cloneNode method)
lastChild (XMLNode.lastChild property)
public lastChild : XMLNode [read-only]
An XMLNode value that references the last child in the node's child list. The XML.lastChild
property is
null if the node does not have children. This property cannot be used to
manipulate child nodes; use the
appendChild(), insertBefore(), and removeNode()
methods to manipulate child nodes.
Availability: ActionScript 1.0; Flash Lite 2.0
Example
The following example uses the
XML.lastChild property to iterate through the child nodes
of an XML node, beginning with the last item in the node's child list and ending with the first
child of the node's child list:
// create a new XML document
var doc:XML = new XML();
// create a root node
var rootNode:XMLNode = doc.createElement("rootNode");
// create three child nodes
var oldest:XMLNode = doc.createElement("oldest");
var middle:XMLNode = doc.createElement("middle");
var youngest:XMLNode = doc.createElement("youngest");
// add the rootNode as the root of the XML document tree