HTML agility pack Select sites with multiple attributes

This may be a simple and stupid question, but I can’t find anything when choosing a node that has several attributes. In my case, this is a special class and a special style.

Here is an HTML snippet I'm working with.

<div class="buying" style="padding-bottom: 0.75em;">
<span class="availGreen">Blah Blah</span><br /> Blah Blah Blah<b>Sold By</b>.
</div>

There are many different instances of the purchase class, but only one div instance that includes both the purchase class and the style = "padding-bottom: 0.75em" attribute. I am trying to capture text inside a tag.

Here is what I tried but didn't get anywhere:

SelectSingleNode("//div[@class='buying'][@style='padding-bottom: 0.75em;']/b").InnerText;

And:

SelectSingleNode("//div[@class='buying' @style='padding-bottom: 0.75em;']/b").InnerText;

None of them gave any results, but I'm not sure what else is right.

Any help is much appreciated!

+5
source share
1 answer

and ( , XPath ):

SelectSingleNode("//div[@class='buying' and @style='padding-bottom: 0.75em;']/b").InnerText;
+10

All Articles