0

Can someone please provide me some sample code to get data from a nested table below. I want data from Row 1 to row 2 all the columns. If there is an ID in the table I am able to grab data, but there is no ID. I pretty much search all over the internet and still could not find an answer. Please help

<div id="Div-content_ID">
<table><tr><td>
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr><td></td></tr>
<tr>
<td >
<table >
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>


<table width="100%" cellpadding="3" cellspacing="1" border="0" bgcolor="#d3d3d3">
<tr align="center" valign="middle">
<td>row1 Col 1</td>
<td >row1 Col 2 </td>
<td >row1 Col 3 </td>
<td >row1 Col 4 </td>
<td >row1 Col 5 </td>
<td >row1 Col 6 </td>
<td >row1 Col 7 </td>
<td >row1 Col 8 </td>
<td >row1 Col 9 </td>
<td >row1 Col 10 </td>
<td >row1 Col 11 </td>
<tr>
<tr>
<td>row2 Col 1</td>
<td >row2 Col 2 </td>
<td >row2 Col 3 </td>
<td >row2 Col 4 </td>
<td >row2 Col 5 </td>
<td >row2 Col 6 </td>
<td >row2 Col 7 </td>
<td >row2 Col 8 </td>
<td >row2 Col 9 </td>
<td >row2 Col 10 </td>
<td >row2 Col 11 </td>
</tr>
<tr>
<td>
<table>


<tr>
<td></td><td></td></tr>
</table>
</td>
</tr>
<tr><td></td></tr>
<tr>
<td</td>
</tr>
<tr><td></td></tr>
</table>
</div>

1 Answers1

0

1) Your HTML is poorly formed:

  • The 1st table never gets closed off properly. There is missing </td> </tr> </table>

  • There's a <td></td> pair near the end that has a missing '>'

2) With HTML Agility Pack you can select on anything, not just id or classes. So, as long as your HTML structure remains the same, you could select the 1st div, then from its children: the 1st table, then from its children: the 4th row, then from its children: the 1st table. etc etc

See here for an example for selecting by table: HTML Agility pack - parsing tables

ash
  • 482
  • 3
  • 9