/// <summary> /// 获取符合条件的子元素 /// </summary> /// <param name="container">要获取子元素的容器</param> /// <param name="selector">用来筛选子元素的元素选择器</param> /// <returns>符合条件的子元素</returns> public static IEnumerable <IHtmlElement> Elements(this IHtmlContainer container, string selector) { if (container == null) { throw new ArgumentNullException("container"); } if (selector == null) { throw new ArgumentNullException("selector"); } return(CssParser.ParseElementSelector(selector).Filter(Elements(container))); }
/// <summary> /// 获取符合条件的兄弟(同级)元素节点 /// </summary> /// <param name="node">要获取兄弟(同级)元素节点的节点</param> /// <param name="selector">用于筛选元素的元素选择器</param> /// <returns>所有的兄弟(同级)元素节点</returns> public static IEnumerable <IHtmlElement> Siblings(this IHtmlNode node, string selector) { return(CssParser.ParseElementSelector(selector).Filter(node.Siblings())); }