HTML Agility Pack Select Nodes with Multiple Attributes

c# html html-agility-pack parsing

Question

I apologize if this is a silly or trivial question, but I can't seem to locate any information on choosing a node with numerous attributes. In my situation, it's a certain class and a particular style.

Here is a sample of the HTML that I am using.

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

While the class "purchasing" appears in several places, the div with the buying class and the style="padding-bottom: 0.75em characteristics only appears once. I'm attempting to seize the tag's text.

Here is what I tried, but it didn't work:

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

As well as:

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

I'm not sure what else is true, but none of them had any effect.

We much appreciate any assistance.

1
6
2/23/2013 7:22:51 PM

Accepted Answer

and might work to link them (I think that's the proper XPath syntax for choosing multiple attributes):

SelectSingleNode("//div[@class='buying' and @style='padding-bottom: 0.75em;']/b").InnerText;
11
2/23/2013 7:09:20 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow