So, I have this pretty long html file, and I need to fill a listview with some of it's elements. I'm just starting off with HtmlAgilityPack, and I have no clue how to even start. My html is as follows:
<html>
<body>
<div class="content_bg">
<div style="width:868px; margin:0px auto">
<div class="main">
<div class="content">
<center>
<div class="content-1col-nobox">
<div style="width:720px;">
<table class="vlist">
<tbody>
<tr>
<td valign="top">
<div class="link">
<a href="http://link i need here/">Text I need here</a>
</div class="link">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</center>
</div>
</div>
</div>
</div>
</body>
</html>
I have a ton of those "tr" elements, and I'm attempting to retrieve all of them using foreach, but that's not my problem. The problem is that I don't know how to get to there. For the moment, I'm trying to use this absolutely chaotic piece of code:
using (HttpClient client = new HttpClient())
{
using (HttpResponseMessage response = await client.GetAsync(("http://vodlocker.com/?op=search&k=" + txtbox.Text)))
{
if (response.IsSuccessStatusCode)
{
using (Stream stream = response.Content.ReadAsStreamAsync().Result)
{
HtmlDocument doc = new HtmlDocument();
doc.Load(stream);
var titleElement = doc.DocumentNode.Element("html").Element("body").Element("div class=\"content_bg\"").Element("div style=\"width: 868px; margin: 0px auto\"").Element("div class=\"main\"").Element("div class=\"content\"").Element("center").Element("div class=\"content - 1col - nobox\"").Element("div style=\"width: 720px;\"").Element("table class=\"vlist\"").Element("tbody");
}
}
}
}
But, suprisingly, it isn't working. I get an "object reference not set to an instance of an object" error on the "var titleElement" line.