/// <summary> /// 根据 xpath 选择 node 集合, node 非 root node /// </summary> /// <remarks>Hesinx 2016-05-26</remarks> /// <param name="navigator"></param> /// <param name="xpath"></param> /// <returns></returns> public static IEnumerable <HtmlNodeNavigator> SelectSet(this HtmlNodeNavigator navigator, string xpath) { return(navigator.ToElement().Select(xpath).Cast <HtmlNodeNavigator>()); //return from HtmlNodeNavigator m in navigator.Select(xpath) select m; }
/// <summary> /// 根据 xpath 选择单个 node, 非 root node /// </summary> /// <param name="navigator"></param> /// <param name="xpath"></param> /// <returns></returns> public static HtmlNodeNavigator SelectSingle(this HtmlNodeNavigator navigator, string xpath) { return(navigator.ToElement().SelectSingleNode(xpath) as HtmlNodeNavigator); }