Vote count:
0
I need help in parsing a HTML file. I'm new to C# and LINQ and everything i tried has not been successfull in extracting the "link" and the "Name 1"
<tr class="Row">
<td width="80">
<div align="left"> <a href="link">details</a>
</div>
</td>
<td width="152">Name 1</td>
<td width="151">Name 2</td>
<td width="152">Name 3</td>
<td width="151">Name 4</td>
<td width="151">Name 5</td>
<td width="152">Name 6</td>
</tr>
<tr class="Row">
<td width="80">
<div align="left"> <a href="link">details</a>
</div>
</td>
<td width="152">Name 1</td>
<td width="151">Name 2</td>
<td width="152">Name 3</td>
<td width="151">Name 4</td>
<td width="151">Name 5</td>
<td width="152">Name 6</td>
</tr>
This is what i tried:
var links = htmlDoc.DocumentNode.Descendants()
.Where(n => n.Name == "tr")
.Where(x => x.Attributes["class"] != null && x.Attributes["class"].Value == "Row")
.Select(x => x.Descendants()
.Where(s => s.Name == "href"));
foreach (var link in links)
{
Debug.WriteLine(link);
}
asked 21 secs ago
Parsing HTML using LINQ
Aucun commentaire:
Enregistrer un commentaire