ActionScript for Flash MX: The Definitive Guide, Second Edition

ActionScript for Flash MX: The Definitive Guide, 2nd EditionBy Colin Moock
Chapter 18.  ActionScript Language Reference
XML.lastChild Property Flash 5

a reference to the last descendant of a node read-only

theNode.lastChild

Description

The lastChild property is synonymous with childNodes[childNodes.length - 1]. It returns a reference to the last node object that descends from theNode, where theNode can be an XML or XMLnode instance. If theNode has no children, lastChild returns null.

In the following XML source fragment, the lastChild of the MESSAGE node is the CONTENT node:

<MESSAGE><USER>gray</USER><CONTENT>hi</CONTENT></MESSAGE>

Example

// Create a new XML document myDoc = new XML('<MESSAGE><USER>gray</USER><CONTENT>hi</CONTENT></MESSAGE>'); // Sets msg to "hi" because myDoc's firstChild // is MESSAGE; MESSAGE's lastChild is CONTENT; and CONTENT's firstChild // is the text node with the value "hi" msg = myDoc.firstChild.lastChild.firstChild.nodeValue

See Also

XML.childNodes, XML.firstChild, XML.nextSibling, XML.previousSibling

    Категории