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

Create() public method

Initialize the AncestorIterator.
public Create ( XPathNavigator context, XmlNavigatorFilter filter, bool orSelf ) : void
context System.Xml.XPath.XPathNavigator
filter XmlNavigatorFilter
orSelf bool
return void
        public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf) {
            this.filter = filter;

            // Save context node as current node
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);

            // If self node matches, then next call to MoveNext() should return it
            // Otherwise, MoveNext() will fetch next ancestor
            this.haveCurrent = (orSelf && !this.filter.IsFiltered(this.navCurrent));
        }

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::Create
AncestorIterator