Esempio n. 1
0
        /// <summary>
        /// Finds the first match for the type, and must match the attributes if they're specified. Option to disable recursive search will only search on the next level if set to false.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        public HtmlItem Get(string type, Dictionary <string, string> attributes = null, bool continueUp = false, bool recursive = true)
        {
            //look through children
            HtmlItem i;

            if ((i = get(type, attributes, recursive)) != null)
            {
                return(i);
            }

            //if we can continue up
            if (continueUp)
            {
                HtmlItem n = next();
                if (n != null)
                {
                    //first check if it matches
                    if (n.IsType(type) && n.HasAttributes(attributes))
                    {
                        return(n);
                    }

                    return(n.Get(type, attributes, continueUp, recursive));
                }
            }

            return(null);
        }
Esempio n. 2
0
        public LinkedList <HtmlItem> GetRange(string type, Dictionary <string, string> attributes)
        {
            HtmlItem stop = Next(false);

            HtmlItem item = this;
            LinkedList <HtmlItem> list = new LinkedList <HtmlItem>();

            while ((item = item.Next()) != stop)
            {
                if (item.IsType(type) && item.HasAttributes(attributes))
                {
                    list.AddLast(item);
                }
            }

            return(list);
        }