Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# html agility pack get elements by class name

Tags:

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?

like image 867
Ofer Gozlan Avatar asked Apr 19 '16 07:04

Ofer Gozlan


1 Answers

I got it:

resultContent.DocumentNode.SelectNodes("//div[contains(@class, 'hello')]") 
like image 132
Ofer Gozlan Avatar answered Sep 19 '22 12:09

Ofer Gozlan