Пример #1
0
        public ElementCollection css(string selector)
        {
            if (string.IsNullOrEmpty(selector))
            {
                return(new ElementCollection());
            }

            // 选择某个属性
            var css = RegexUnity.AttrSelector(selector);

            if (!string.IsNullOrEmpty(css))
            {
                ElementCollection eles = new ElementCollection();
                ElementIterator.Each(this, (item) =>
                {
                    if (!string.IsNullOrEmpty(item.attr(css)))
                    {
                        eles.Add(item);
                    }
                    return(true);
                });
                return(eles);
            }

            return(new ElementCollection(from node in this._innerNode.CssSelect(selector)
                                         select new Element(node)));
        }
Пример #2
0
        internal static Element Single(Element parentNode, Func <Element, bool> filtter)
        {
            Element target = null;

            ElementIterator.Each(parentNode, (item) =>
            {
                if (filtter(item))
                {
                    target = item;
                    return(true);
                }
                return(false);
            });
            return(target);
        }