public HtmlNode SelectSingleNode(string xpath) { if (xpath == null) { throw new ArgumentNullException(nameof(xpath)); } XPathNodeIterator xpathNodeIterator = new HtmlNodeNavigator(this.OwnerDocument, this).Select(xpath); if (!xpathNodeIterator.MoveNext()) { return((HtmlNode)null); } return(((HtmlNodeNavigator)xpathNodeIterator.Current).CurrentNode); }
public HtmlNode SelectSingleNode(string xpath) { if (xpath == null) { throw new ArgumentNullException("xpath"); } XPathNodeIterator iterator = new HtmlNodeNavigator(OwnerDocument, this).Select(xpath); if (!iterator.MoveNext()) { return(null); } HtmlNodeNavigator current = (HtmlNodeNavigator)iterator.Current; return(current.CurrentNode); }
public HtmlNodeCollection SelectNodes(string xpath) { HtmlNodeCollection nodes = new HtmlNodeCollection(null); XPathNodeIterator iterator = new HtmlNodeNavigator(OwnerDocument, this).Select(xpath); while (iterator.MoveNext()) { HtmlNodeNavigator current = (HtmlNodeNavigator)iterator.Current; nodes.Add(current.CurrentNode); } if (nodes.Count == 0) { return(null); } return(nodes); }
public HtmlNodeCollection SelectNodes(string xpath) { HtmlNodeCollection htmlNodeCollection = new HtmlNodeCollection((HtmlNode)null); XPathNodeIterator xpathNodeIterator = new HtmlNodeNavigator(this.OwnerDocument, this).Select(xpath); while (xpathNodeIterator.MoveNext()) { HtmlNodeNavigator current = (HtmlNodeNavigator)xpathNodeIterator.Current; htmlNodeCollection.Add(current.CurrentNode); } if (htmlNodeCollection.Count == 0) { return((HtmlNodeCollection)null); } return(htmlNodeCollection); }
/// <summary> /// Selects the first XmlNode that matches the XPath expression. /// /// </summary> /// <param name="xpath">The XPath expression. May not be null.</param> /// <returns> /// The first <see cref="T:HtmlAgilityPack.HtmlNode"/> that matches the XPath query or a null reference if no matching node was found. /// </returns> public HtmlNode SelectSingleNode(string xpath) { if (xpath == null) throw new ArgumentNullException("xpath"); XPathNodeIterator xpathNodeIterator = new HtmlNodeNavigator(this.OwnerDocument, this).Select(xpath); if (!xpathNodeIterator.MoveNext()) return (HtmlNode) null; return ((HtmlNodeNavigator) xpathNodeIterator.Current).CurrentNode; }
/// <summary> /// Selects a list of nodes matching the <see cref="P:HtmlAgilityPack.HtmlNode.XPath"/> expression. /// /// </summary> /// <param name="xpath">The XPath expression.</param> /// <returns> /// An <see cref="T:HtmlAgilityPack.HtmlNodeCollection"/> containing a collection of nodes matching the <see cref="P:HtmlAgilityPack.HtmlNode.XPath"/> query, or <c>null</c> if no node matched the XPath expression. /// </returns> public HtmlNodeCollection SelectNodes(string xpath) { HtmlNodeCollection htmlNodeCollection = new HtmlNodeCollection((HtmlNode) null); XPathNodeIterator xpathNodeIterator = new HtmlNodeNavigator(this.OwnerDocument, this).Select(xpath); while (xpathNodeIterator.MoveNext()) { HtmlNodeNavigator htmlNodeNavigator = (HtmlNodeNavigator) xpathNodeIterator.Current; htmlNodeCollection.Add(htmlNodeNavigator.CurrentNode); } if (htmlNodeCollection.Count == 0) return (HtmlNodeCollection) null; return htmlNodeCollection; }