C# html agility pack get elements by class name

c# html html-agility-pack

Question

I'm trying to get all the divs that their class contains a certain word:

<div class="hello mike">content1</div>
<div class="hello jeff>content2</div>
<div class="john">content3</div>

I need to get all the divs that their class contains the word "hello". Something like this:

resultContent.DocumentNode.SelectNodes("//div[@class='hello']"))

how can i do it with agility pack?

Popular Answer

I got it:

resultContent.DocumentNode.SelectNodes("//div[contains(@class, 'hello')]"))



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why