Name
XML.previousSibling Property — a reference to the node before this node
Availability
Flash 5
Synopsis
theNode.previousSibling
Access
Read-only
Description
The previousSibling
property returns a reference
to the node object preceding theNode
in
the current level of the XML object hierarchy. If there is no node
before theNode
in the current level of the
hierarchy, it returns null
.
In the following XML source fragment, the
previousSibling
of the CONTENT
node is the USER
node:
<MESSAGE><USER>gray</USER><CONTENT>hi</CONTENT></MESSAGE>
Example
The previousSibling
property can be used to
traverse an XML object hierarchy, although
nextSibling
is more commonly used for this
purpose. To view all the children of
theNode
in reverse order, we may use:
for (var i = theNode.lastChild; i != null; i = i.previousSibling) { trace("found node: " + i.nodeName); }
See Also
XML
.childNodes
,
XML
.firstChild
,
XML
.lastChild
,
XML
.nextSibling
,
XML
.nodeName
,
XML
.nodeValue
,
XML
.parentNode
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.