/// <summary> /// Gets the last attribute of child node that have attribute by given name and value of this element. /// </summary> /// <param name="elementName">Use wildcards(*) to search in all elements</param> public static HtmlAgilityPack.HtmlAttribute SelectLastChildAttribute(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue) { return(source.ChildrenSelector(elementName).FirstOrDefault(s => s.HasAttribute(attributeName, attributeValue))?.Attributes[attributeName]); }
/// <summary> /// Gets the last child node that have attribute by given name of this element. /// </summary> /// <param name="elementName">Use wildcards(*) to search in all elements</param> public static HtmlAgilityPack.HtmlNode SelectLastChild(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName) { return(source.ChildrenSelector(elementName).LastOrDefault(s => s.HasAttribute(attributeName))); }
/// <summary> /// Gets the first child node by given name of this element. /// </summary> public static HtmlAgilityPack.HtmlNode SelectFirstChild(this HtmlAgilityPack.HtmlNode source, string elementName) { return(source.ChildrenSelector(elementName).FirstOrDefault()); }
/// <summary> /// Gets the collection of attributes of matching elements. /// </summary> /// <param name="elementName">Use wildcards(*) to match all elements</param> public static IEnumerable <HtmlAgilityPack.HtmlAttribute> SelectChildrenAttributes(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue) { return(source.ChildrenSelector(elementName).Where(w => w.HasAttribute(attributeName, attributeValue)).Select(s => s.Attributes[attributeName])); }
/// <summary> /// Returns a collection of all children nodes that have attribute by given name of this element. /// </summary> /// <param name="elementName">Use wildcards(*) to match all elements</param> public static IEnumerable <HtmlAgilityPack.HtmlNode> SelectChildren(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName) { return(source.ChildrenSelector(elementName).Where(w => w.HasAttribute(attributeName))); }
/// <summary> /// Returns a collection of all children nodes by given name of this element. /// </summary> public static IEnumerable <HtmlAgilityPack.HtmlNode> SelectChildren(this HtmlAgilityPack.HtmlNode source, string elementName) { return(source.ChildrenSelector(elementName)); }