/// <summary> /// Get first instance of node or attribute in supplied collection /// </summary> /// <param name="items">The collection fo find first node in</param> /// <param name="name">Name of the node to find</param> /// <returns>First node or attribute with matching name</returns> public static IHtmlNode FindFirst(HtmlCollection <T> items, string name) { foreach (T node in items) { if (node.Name.ToLower().Contains(name)) { return(node); } if (!node.HasChildNodes) { continue; } IHtmlNode returnNode = HtmlNodeCollection.FindFirst(node.ChildNodes, name); if (returnNode != null) { return(returnNode); } } return(null); }
public static HtmlNode FindFirst(HtmlNodeCollection items, string name) { foreach (HtmlNode current in (IEnumerable <HtmlNode>)items) { if (current.Name.ToLower().Contains(name)) { HtmlNode result = current; return(result); } if (current.HasChildNodes) { HtmlNode htmlNode = HtmlNodeCollection.FindFirst(current.ChildNodes, name); if (htmlNode != null) { HtmlNode result = htmlNode; return(result); } } } return(null); }
public HtmlNode FindFirst(string name) { return(HtmlNodeCollection.FindFirst(this, name)); }