Example #1
0
 /// <summary>
 /// Returns a collection of all descendant nodes that have attribute by given name and value of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to match all elements</param>
 public static IEnumerable <HtmlAgilityPack.HtmlNode> SelectDescendants(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, false).Where(w => w.HasAttribute(attributeName, attributeValue)));
 }
Example #2
0
 /// <summary>
 /// Gets the first attribute of descendant node or self 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 SelectFirstDescendantAttributeWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).FirstOrDefault(s => s.HasAttribute(attributeName, attributeValue))?.Attributes[attributeName]);
 }
Example #3
0
 /// <summary>
 /// Gets the single descendant node or self 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.HtmlNode SelectSingleDescendantWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).SingleOrDefault(s => s.HasAttribute(attributeName, attributeValue)));
 }
Example #4
0
 /// <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> SelectDescendantsAttributesWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).Where(w => w.HasAttribute(attributeName, attributeValue)).Select(s => s.Attributes[attributeName]));
 }
Example #5
0
 /// <summary>
 /// Gets the first descendant 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.HtmlNode SelectFirstDescendant(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, false).FirstOrDefault(s => s.HasAttribute(attributeName, attributeValue)));
 }
Example #6
0
 /// <summary>
 /// Gets the single attribute of descendant 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 SelectSingleDescendantAttribute(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, false).SingleOrDefault(s => s.HasAttribute(attributeName, attributeValue))?.Attributes[attributeName]);
 }