System.Xml.Xsl.Runtime.AncestorIterator.MoveNext C# (CSharp) Method

MoveNext() public method

Position the iterator on the next matching ancestor node. Return true if such a node exists and set Current property. Otherwise, return false (Current property is undefined).
public MoveNext ( ) : bool
return bool
        public bool MoveNext() {
            if (this.haveCurrent) {
                this.haveCurrent = false;
                return true;
            }

            while (this.navCurrent.MoveToParent()) {
                if (!this.filter.IsFiltered(this.navCurrent))
                    return true;
            }

            // Iteration is complete
            return false;
        }

Usage Example

        /// <summary>
        /// Initialize the AncestorDocOrderIterator (return ancestor nodes in document order, no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf)
        {
            AncestorIterator wrapped = new AncestorIterator();

            wrapped.Create(context, filter, orSelf);

            // Fetch all ancestor nodes in reverse document order and push them onto the stack
            while (wrapped.MoveNext())
            {
                stack.Push(wrapped.Current.Clone());
            }
        }
All Usage Examples Of System.Xml.Xsl.Runtime.AncestorIterator::MoveNext
AncestorIterator