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

MoveNext() public method

Position this iterator to the next preceding node. Return false if there are no more preceding nodes. Return true if the Current property is set to the next node in the iteration.
public MoveNext ( ) : bool
return bool
        public bool MoveNext() {
            if (!this.navStack.IsEmpty) {
                while (true) {
                    // Move to the next matching node that is before the top node on the stack in document order
                    if (this.filter.MoveToFollowing(this.navCurrent, this.navStack.Peek()))
                        // Found match
                        return true;

                    // Do not include ancestor nodes as part of the preceding axis
                    this.navCurrent.MoveTo(this.navStack.Pop());

                    // No more preceding matches possible
                    if (this.navStack.IsEmpty)
                        break;
                }
            }

            return false;
        }

Usage Example

        /// <summary>
        /// Initialize the XPathPrecedingIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            XPathPrecedingDocOrderIterator wrapped = new XPathPrecedingDocOrderIterator();

            wrapped.Create(context, filter);

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