This project has moved. For the latest updates, please go here.

Parse html based on classname with HtmlAgilityPack

Topics: User Forum
Oct 16, 2012 at 6:58 PM


I'm just getting started with HtmlAgilityPack and I could use some help. I'm not sure if what i want to do can be done with HtmlAgilityPack, though i search the internet for resources.

I would like to parse a complex html file and save inner text into a table as I show in pseudocode below.

I tried some of the examples I found but none of them can get the inner text based on the classname and not the id.

read ("test.html");

search only body

for each element <table r=i> (i=1; i<50; i++)

if element is <div class="first" -->write innerText into a table at place [i][column1]

if element is <div class="second" --> write innerText into the same table in [i][column2]

I would appreciate any kind of help.

Thank you in advance.