XMLNode
755
Example
The following example creates an XML packet and displays the parent node of the username
node in the Output panel:
var my_xml:XML = new XML("mortongood&evil");
// first child is the <login /> node
var rootNode:XMLNode = my_xml.firstChild;
// first child of the root is the <username /> node
var targetNode:XMLNode = rootNode.firstChild;
trace("the parent node of '"+targetNode.n"' is:
"+targetNode.parentNode.nodeName);
trace("contents of the parent node are:\n"+targetNode.parentNode);
// output (line breaks added for clarity):
the parent node of 'username' is: login
contents of the parent node are:
morton
good&evil
See also
appendChild (XMLNode.appendChild method)
,
insertBefore (XMLNode.insertBefore
method)
,
removeNode (XMLNode.removeNode method)
,
XML
previousSibling (XMLNode.previousSibling property)
public previousSibling :
XMLNode
[read-only]
An XMLNode value that references the previous sibling in the parent node's child list. The
property has a value of null if the node does not have a previous sibling node. 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 is an excerpt from the example for the
XML.lastChild
property, and
shows how you can use the
XML.previousSibling
property to loop through an XML node's
child nodes:
for (var aNode:XMLNode = rootNode.lastChild; aNode != null; aNode =
aNode.previousSibling) {
trace(aNode);
}
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...