This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net.Mime; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Xml.Linq; | |
using HtmlAgilityPack; | |
using System.Xml; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseHtml() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var cells = htmlDoc.DocumentNode | |
.SelectNodes("/html/body/div[2]/div[4]/div/div[3]/table/tbody/tr/td") // use the right XPath rather than looping manually | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); | |
var elementNames = new[] { "Name", "Team", "Pos", "GP", "G", "A", "Pts", "PlusMinus", "PIM", "PP", "SH", "GW", "OT", "Shots", "ShotPctg", "TOIPerGame", "ShiftsPerGame", "FOWinPctg" }; | |
var xmlDoc = new XElement("Stats", new XAttribute("Date", DateTime.Now.ToShortDateString()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseHtml() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var cells = htmlDoc.DocumentNode | |
.SelectNodes("/html/body/div[2]/div[4]/div/div[3]/table/tbody/tr/td") // use the right XPath rather than looping manually | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); | |
var elementNames = new[] { "Name", "Team", "Pos", "GP", "G", "A", "Pts", "PlusMinus", "PIM", "PP", "SH", "GW", "OT", "Shots", "ShotPctg", "TOIPerGame", "ShiftsPerGame", "FOWinPctg" }; | |
var xmlDoc = new XElement("Stats", new XAttribute("Date", DateTime.Now.ToShortDateString()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseHtml() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var cells = htmlDoc.DocumentNode | |
.SelectNodes("/html/body/div[2]/div[4]/div/div[3]/table/tbody/tr[THIS tr changes to tr[1] etc for each xpath needed]/td") // use the right XPath rather than looping manually | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); | |
var elementNames = new[] { "Name", "Team", "Pos", "GP", "G", "A", "Pts", "PlusMinus", "PIM", "PP", "SH", "GW", "OT", "Shots", "ShotPctg", "TOIPerGame", "ShiftsPerGame", "FOWinPctg" }; | |
var xmlDoc = new XElement("Stats", new XAttribute("Date", DateTime.Now.ToShortDateString()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseHtml() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var cells = htmlDoc.DocumentNode | |
.SelectNodes("//table[@class='data stats']/tbody/tr/td") // can't get it to loop | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cells = htmlDoc.DocumentNode | |
.SelectNodes ("//table[@class='data stats']/tbody/tr/td") OfType<XmlNode>() // can't get it to loop | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseHtml() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var cells = htmlDoc.DocumentNode | |
.SelectNodes("//table[@class='data stats']/tbody/tr/td").OfType<XmlNode>()// can't get it to loop | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseTeams() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var teamName = htmlDoc.DocumentNode | |
.SelectNodes("//select[@id='team']//option[position() > 1]") | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseTeams() | |
{ | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.LoadHtml(Source); | |
var teamName = htmlDoc.DocumentNode | |
.SelectNodes("//select[@id='team']//option[position() > 1]") | |
.Select(node => node.InnerText.Trim()) | |
.ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ParseTeams() | |
{ | |
HtmlAgilityPack.HtmlNode.ElementsFlags.Remove("option"); | |
var htmlDoc = new HtmlDocument(); | |
htmlDoc.OptionFixNestedTags = true; | |
htmlDoc.LoadHtml(Source); | |
var teamName = htmlDoc.DocumentNode | |
.SelectNodes("//select[@id='team']//option[position() > 1]") |