XML.previousSibling Property | Flash 5 |
a reference to the node before this node | read-only |
The previousSibling property returns a reference to the node object preceding theNode in the current level of the XML object hierarchy (theNode can be an XML or XMLnode instance). 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>
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 can use:
for (var i = theNode.lastChild; i != null; i = i.previousSibling) { trace("found node: " + i.nodeName); }
XML.childNodes, XML.firstChild, XML.lastChild, XML.nextSibling, XML.nodeName, XML.nodeValue, XML.parentNode