I have to make project for school in C# which has to use database and web service. I have made a program which starts a web service and gets a function from there which is used for connecting to a website. I am using HTML Agility Pack for parsing info from that website. Website info is then written in textbox and stored in database.
Here is one function from project, and the rest is here.
public void HtmlParser()
{
Encoding enc = Encoding.UTF8;
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.Load(client.Request(), enc);
HtmlNode root = htmlDoc.DocumentNode;
HtmlNodeCollection jobNode = root.SelectNodes("//div[@class='jobBox']");
HtmlNodeCollection headerNode = root.SelectNodes("//div[@class='jobBox']/h1");
HtmlNodeCollection contentNode = root.SelectNodes("//div[@class='jobBox']/div[@class='content']");
HtmlNodeCollection linkNode = root.SelectNodes("//div[@class='jobBox']/a");
jobs = new List<string>();
headers = new List<string>();
content = new List<string>();
links = new List<string>();
full_links = new List<Uri>();
foreach (HtmlNode node in jobNode)
{
jobs.Add(node.InnerText);
}
foreach (HtmlNode node in headerNode)
{
headers.Add(node.InnerText.Trim());
}
foreach (HtmlNode node in contentNode)
{
content.Add(node.InnerText.Trim());
}
foreach (HtmlNode node in linkNode)
{
links.Add(node.GetAttributeValue("href", null).Trim());
Uri temp = new Uri(link + node.GetAttributeValue("href", null).Trim());
full_links.Add(temp);
}
htmlDoc.Save("file.htm", enc);
StringParser();
}
Some variables are in Croatian, so don't get confused. I am looking for helpful reviews and tips on how I can make my code better.