System.Xml.XPath.XPathNavigator.MoveToFollowing C# (CSharp) Method

MoveToFollowing() public method

public MoveToFollowing ( XPathNodeType type, XPathNavigator end ) : bool
type XPathNodeType
end XPathNavigator
return bool
        public virtual bool MoveToFollowing(XPathNodeType type, XPathNavigator end)
        {
            XPathNavigator navSave = Clone();
            int mask = GetContentKindMask(type);

            if (end != null)
            {
                switch (end.NodeType)
                {
                    case XPathNodeType.Attribute:
                    case XPathNodeType.Namespace:
                        // Scan until we come to the next content-typed node 
                        // after the attribute or namespace node
                        end = end.Clone();
                        end.MoveToNonDescendant();
                        break;
                }
            }
            switch (NodeType)
            {
                case XPathNodeType.Attribute:
                case XPathNodeType.Namespace:
                    if (!MoveToParent())
                    {
                        return false;
                    }
                    break;
            }
            do
            {
                if (!MoveToFirstChild())
                {
                    // Look for next sibling
                    while (true)
                    {
                        if (MoveToNext())
                            break;

                        if (!MoveToParent())
                        {
                            // Restore previous position and return false
                            MoveTo(navSave);
                            return false;
                        }
                    }
                }

                // Have we reached the end of the scan?
                if (end != null && IsSamePosition(end))
                {
                    // Restore previous position and return false
                    MoveTo(navSave);
                    return false;
                }
            }
            while (((1 << (int)NodeType) & mask) == 0);

            return true;
        }

Same methods

XPathNavigator::MoveToFollowing ( XPathNodeType type ) : bool
XPathNavigator::MoveToFollowing ( string localName, string namespaceURI ) : bool
XPathNavigator::MoveToFollowing ( string localName, string namespaceURI, XPathNavigator end ) : bool

Usage Example

        public IList<string> GrabBackDropUrls(XPathNavigator nav)
        {
            List<string> urls = new List<string>();
            XPathNodeIterator nIter = nav.SelectChildren("backdrop", "");
            if (nav.MoveToFollowing("backdrop", ""))
            {
                XPathNavigator localNav = nav.CreateNavigator();
                nav.MoveToParent();
                for (int i = 0; i < nIter.Count; i++)
                {
                    if (localNav.GetAttribute("size", "").ToUpperInvariant().Equals("original".ToUpperInvariant()))
                        urls.Add(localNav.Value);

                    localNav.MoveToNext();
                }
            }
            return urls;
        }
All Usage Examples Of System.Xml.XPath.XPathNavigator::MoveToFollowing