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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access