public static void Show(HtmlNode docNode) { Color holder = Console.ForegroundColor; Console.ForegroundColor = Color.Yellow; HtmlNode LUContainer = docNode.SelectSingleNode("//div[@class=\"lineups\"]"); HtmlNodeCollection lineups = LUContainer.SelectSingleNode("./div") .SelectNodes("./div[@class=\"lineup standard-box\"]"); //2 headers for lineup and rank, 5 data for players List <List <string> > lineupData = Etc.GenerateEmptyListWithHeaders(7); foreach (HtmlNode lineup in lineups) { string teamName = lineup.SelectSingleNode(".//a[@class=\"text-ellipsis\"]").InnerText; string teamRank = lineup.SelectSingleNode(".//div[@class=\"teamRanking\"]").InnerText; lineupData[0].Add(teamName); lineupData[1].Add(teamRank); HtmlNodeCollection players = lineup.SelectNodes(".//td[@class=\"player\"]"); for (int i = 0; i < players.Count; i++) { HtmlNode flagNode = players[i].SelectSingleNode(".//img[contains(@class, 'flag')]"); string flag = "[" + flagNode.GetAttributeValue("title", "Flagless") + "]"; string name = players[i].SelectSingleNode(".//div[@class=\"text-ellipsis\"]").InnerText; lineupData[i + 2].AddRange(new string[] { flag, name }); } } Console.WriteLine("\n"); PrintLineup(lineupData); Console.WriteLine("\n"); Console.ForegroundColor = holder; }
public static void Show(HtmlNode docNode) { Console.WriteLine("\n"); //makes a list filled with 7 empty string arrays to be populated w/ match data List <List <string> > PMData = Etc.GenerateEmptyListWithHeaders(); HtmlNode PMNode = docNode.SelectSingleNode("//div[@class=\"past-matches\"]"); HtmlNodeCollection teamPMs = PMNode.SelectNodes(".//div[contains(@class, 'standard-box')]"); foreach (HtmlNode teamPM in teamPMs) { HtmlNode headline = teamPM.SelectSingleNode("./div[@class=\"box-headline\"]"); string teamName = headline.SelectSingleNode(".//a").InnerText; PMData[0].Add(teamName); HtmlNodeCollection matches = teamPM.SelectNodes(".//tr[@class=\"table\"]"); for (int i = 0; i < matches.Count; i++) { HtmlNodeCollection matchRows = matches[i].SelectNodes(".//td"); string format = matchRows[0].SelectSingleNode(".//a").InnerText; string opponent = matchRows[1].SelectSingleNode(".//a").InnerText; string score = matchRows[2].InnerText; List <string> scoreClass = matchRows[2].GetClasses().ToList(); //eg. ["Best of 3", "Clown9", "2-0", "-16434134"] List <string> toAdd = new List <string>(new string[] { format, opponent, score, ( (scoreClass.Contains("won")) ? Etc.WON.ToArgb().ToString() : (scoreClass.Contains("lost")) ? Etc.LOST.ToArgb().ToString() : Etc.DEFAULT_FG.ToArgb().ToString() ) }); //+1 to make up for the header PMData[i + 1].AddRange(toAdd); } } PrintPastMatches(PMData); }