Extracting table rows with a particular attribute from an HTML File, using HTMLAgilityPack
- by Soham
Consider this html snippet:
<tr>
<td valign=top class="tim_new"><a href="/stocks/company_info/pricechart.php?sc_did=MI42" class="tim_new">3M India</a></td>
<td class="tim_new" valign=top><a href='/stocks/marketstats/indcomp.php?optex=NSE&indcode=Diversified' class=tim>Diversified</a></td>
<td class="tim_new" align=right valign=top>2,487.25</td>
<td class="tim_new" align=right valign=top><font color=#16a903>187.25</font></td>
<td class="tim_new" align=right valign=top><font color=#16a903>8.14</font></td>
<td class="tim_new" align=right valign=top>2,801.90</td>
<td class="tim_new" align=right valign=top>0.06</td>
</tr>
Realize these three things:
The HTML file from which this snippet has been taken, contains multiple number of HTML tables.
The table from which this snippet has been extracted doesnt contain only rows of the shown format, but also of other formats like this, for example:
<tr><td colspan=7><img src="http://img1.moneycontrol.com/images/blank.gif"height="5"></td></tr>`
This same table contains multiple rows of the format which I need to extract.
So given this scenario, is it possible to run a code, which extracts, the link with the class name = "tim_new"?
Help Appreciated,
Soham