Html Agility Pack-Schleife durch Tabellenzeilen und -spalten
Ich habe einen Tisch wie diesen
<table border="0" cellpadding="0" cellspacing="0" id="table2">
<tr>
<th>Name
</th>
<th>Age
</th>
</tr>
<tr>
<td>Mario
</td>
<th>Age: 78
</td>
</tr>
<tr>
<td>Jane
</td>
<td>Age: 67
</td>
</tr>
<tr>
<td>James
</td>
<th>Age: 92
</td>
</tr>
</table>
Und möchten HTML Agility Pack verwenden, um es zu analysieren. Ich habe diesen Code ohne Erfolg ausprobiert:
foreach (HtmlNode row in doc.DocumentNode.SelectNodes("//table[@id='table2']//tr"))
{
foreach (HtmlNode col in row.SelectNodes("//td"))
{
Response.Write(col.InnerText);
}
}
Was mache ich falsch?