0
votes

I am trying to get a collection of nodes from the yahoo nfl sports page....

string path = "http://sports.yahoo.com/nfl/scoreboard";

       HtmlWeb page = new HtmlWeb();
       var score_page = page.Load(path);

       HtmlNodeCollection scores = score_page.DocumentNode.SelectNodes("//*[@tr class='game']/td");

this code returns null ....not sure why!

can someone help with this?

Thank You

1
Looking at the source code, the class isn't "Game" but "game link" - jessehouwing
yes, it seems the name of the class has changed since I posted. I use Google Chrome "inspect element" to find the xpath. I changed the code to "game link" and it is working now! - SuncoastOwner

1 Answers

0
votes

HtmlAgilityPack looks at the full attribute contents and doesn't parse it to split the Class into "Game" and "Link", instead it just sees "game link". If you want to check for a class containing "game", use the contains() function of xpath instead, or use an extension to the HTML Agility Path that allows you to do CSS selectors, such as Fizzler.