Example #1
0
        private bool FindGameId()
        {
            NHLDotComFetch fetch = new NHLDotComFetch();
            String         xml   = NHLDotComFetch.GetPageString(gameListPath);

            if (xml != null && xml.IndexOf("<?xml") >= 0)
            {
                xml = xml.Substring(xml.IndexOf("<?xml"));

                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);

                XmlNodeList nodes = document.SelectNodes("//home-tab/schedule/category[@type=\"NHL\"]/game");
                foreach (XmlNode node in nodes)
                {
                    string   time = node.Attributes["date"].Value;
                    DateTime date = DateTime.Parse(time);

                    if ((date.Year == DateTime.Now.Year && date.Month == DateTime.Now.Month && date.Day == DateTime.Now.Day))
                    {
                        XmlNode homeTeam = node.SelectNodes("home-team")[0];
                        XmlNode awayTeam = node.SelectNodes("visiting-team")[0];

                        if (homeTeam.Attributes["name"].Value.ToLower().CompareTo(homeTeamName) == 0 &&
                            awayTeam.Attributes["name"].Value.ToLower().CompareTo(awayTeamName) == 0)
                        {
                            gameId = Convert.ToInt32(node.Attributes["eventId"].Value);
                            break;
                        }
                    }
                }
            }
            else
            {
                System.Console.WriteLine("Couldn't find game id");
            }

            return(gameId != null);
        }