示例#1
0
文件: HtmlNode.cs 项目: ttrr1/Midea
        public HtmlNode SelectSingleNode(string xpath)
        {
            if (xpath == null)
            {
                throw new ArgumentNullException("xpath");
            }
            XPathNodeIterator iterator = new HtmlNodeNavigator(this._ownerdocument, this).Select(xpath);

            if (!iterator.MoveNext())
            {
                return(null);
            }
            HtmlNodeNavigator current = (HtmlNodeNavigator)iterator.Current;

            return(current.CurrentNode);
        }
示例#2
0
文件: HtmlNode.cs 项目: ttrr1/Midea
        public HtmlNodeCollection SelectNodes(string xpath)
        {
            HtmlNodeCollection nodes    = new HtmlNodeCollection(null);
            XPathNodeIterator  iterator = new HtmlNodeNavigator(this._ownerdocument, this).Select(xpath);

            while (iterator.MoveNext())
            {
                HtmlNodeNavigator current = (HtmlNodeNavigator)iterator.Current;
                nodes.Add(current.CurrentNode);
            }
            if (nodes.Count == 0)
            {
                return(null);
            }
            return(nodes);
        }