GetElementFollowing() public static method

Get the next element node that: 1. Follows the current node in document order (includes descendants, unlike XPath following axis) 2. Precedes the ending node in document order (if pageEnd is null, then all following nodes in the document are considered) 3. Has the specified QName If no such element exists, then do not set pageCurrent or idxCurrent and return false. Assume that the localName has been atomized with respect to this document's name table, but not the namespaceName.
public static GetElementFollowing ( XPathNode &pageCurrent, int &idxCurrent, XPathNode pageEnd, int idxEnd, string localName, string namespaceName ) : bool
pageCurrent XPathNode
idxCurrent int
pageEnd XPathNode
idxEnd int
localName string
namespaceName string
return bool
        /// <summary>
        /// Move to the next element that:
        ///   1. Follows the current node in document order (includes descendants, unlike XPath following axis)
        ///   2. Precedes "end" in document order (if end is null, then all following nodes in the document are considered)
        ///   3. Has the specified QName
        /// Return false if the current node has no matching following elements.
        /// </summary>
        public override bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
        {
            XPathNode[] pageEnd;
            int         idxEnd;

            if ((object)localName != (object)_atomizedLocalName)
            {
                _atomizedLocalName = (localName != null) ? NameTable.Get(localName) : null;
            }

            // Get node on which scan ends (null if rest of document should be scanned)
            idxEnd = GetFollowingEnd(end as XPathDocumentNavigator, false, out pageEnd);

            // If this navigator is positioned on a virtual node, then compute following of parent
            if (_idxParent != 0)
            {
                if (!XPathNodeHelper.GetElementFollowing(ref _pageParent, ref _idxParent, pageEnd, idxEnd, _atomizedLocalName, namespaceURI))
                {
                    return(false);
                }

                _pageCurrent = _pageParent;
                _idxCurrent  = _idxParent;
                _pageParent  = null;
                _idxParent   = 0;
                return(true);
            }

            return(XPathNodeHelper.GetElementFollowing(ref _pageCurrent, ref _idxCurrent, pageEnd, idxEnd, _atomizedLocalName, namespaceURI));
        }
Example #2
0
        public override bool MoveToFollowing(string localName, string namespaceURI, XPathNavigator end)
        {
            XPathNode[] nodeArray;
            if (localName != this.atomizedLocalName)
            {
                this.atomizedLocalName = (localName != null) ? this.NameTable.Get(localName) : null;
            }
            int idxEnd = this.GetFollowingEnd(end as XPathDocumentNavigator, false, out nodeArray);

            if (this.idxParent == 0)
            {
                return(XPathNodeHelper.GetElementFollowing(ref this.pageCurrent, ref this.idxCurrent, nodeArray, idxEnd, this.atomizedLocalName, namespaceURI));
            }
            if (!XPathNodeHelper.GetElementFollowing(ref this.pageParent, ref this.idxParent, nodeArray, idxEnd, this.atomizedLocalName, namespaceURI))
            {
                return(false);
            }
            this.pageCurrent = this.pageParent;
            this.idxCurrent  = this.idxParent;
            this.pageParent  = null;
            this.idxParent   = 0;
            return(true);
        }