NextNonDescendantElementInTree Property

Pageflex Document Action API

Pageflex Document Action API NextNonDescendantElementInTree Property
Namespaces > Pageflex.Scripting > Element > NextNonDescendantElementInTree
Gets the next Element (in a depth-first traversal of the document tree) which is not a descendant of this element.
Syntax
C# Visual Basic Managed C++
public Element NextNonDescendantElementInTree { get; }
Public ReadOnly Property NextNonDescendantElementInTree As Element
public:
Element^ NextNonDescendantElementInTree {
	Element^ get ();
}
Remarks
Returns the next tree Element which is not a descendant of this element, or nullNothingnullptr if there is no such element.

This method is useful for traversing a subtree of document elements, such as all elements contained in a particular page or area template. For example, the following method counts all descendants of a particular "root" element. It uses NextElementInTree to traverse the elements, stopping when it reaches NextNonDescendantElementInTree.

 1static public uint CountDescendants(Element root)
 2
 3{
 4
 5    uint count = 0;
 6
 7    Element sentinelElement = root.NextNonDescendantElementInTree;
 8
 9    for (Element e = root; e != sentinelElement; e = e.NextElementInTree)
10
11        count++;
12
13    return count;
14
15}
Exceptions
Exception Condition
StaleScriptingObjectException This object's associated internal object no longer exists.

Assembly: PFScript Version: 8.0.7.1407 (Module: PFScript)