Extracting table rows with a particular attribute from an HTML File, using HTMLAgilityPack

Posted by Soham on Stack Overflow See other posts from Stack Overflow or by Soham
Published on 2010-06-05T12:20:58Z Indexed on 2010/06/05 12:42 UTC
Read the original article Hit count: 360

Filed under:
|
|

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:

  1. The HTML file from which this snippet has been taken, contains multiple number of HTML tables.

  2. 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>`
    
  3. 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

© Stack Overflow or respective owner

Related posts about c#

Related posts about html