Exemplo n.º 1
0
            public List<Game> GetGameList()
            {
                XmlDocument doc = new XmlDocument ();
                doc.Load(" http://thegamesdb.net/api/GetGamesList.php?name=halo");//test location

                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Data/Game");

                List<Game> games = new List<Game>();

                foreach (XmlNode node in nodes)
                {
                    Game game = new Game();

                    game.id = node.SelectSingleNode("id").InnerText;
                    game.title = node.SelectSingleNode("GameTitle").InnerText;
                    if (node.SelectSingleNode ("ReleaseDate") != null) {
                        game.releaseDate = node.SelectSingleNode ("ReleaseDate").InnerText;
                    }
                    game.platform=node.SelectSingleNode("Platform").InnerText;

                    games.Add(game);
                }

                int x=games.Count;
                /*for (int y = 0; y < x; y++)
                {
                    Console.WriteLine("The ID is: " + games[y].id);
                    Console.WriteLine("The Title of the Game is: " + games[y].title);
                    Console.WriteLine("The Release Date of the Game is: " + games[y].releaseDate);
                    Console.WriteLine("The Platform of the Game is: " + games[y].platform);

                }*/
                //Console.ReadLine();
                return games;
            }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     Game PlaceHolder = new Game ();
     List<Game> TestModule = new List<Game> ();
     TestModule = PlaceHolder.GetGameList ();
     Console.WriteLine (TestModule [1].id+"got here!!!");
     Console.ReadLine ();
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            XmlDocument doc = new XmlDocument ();
            doc.Load(@"C:\Users\kylej_000\Documents\GitHub\TheGameDB\XMLReaderFolder\testing_gameList.xml");//test location

            XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Data/Game");

            List<Game> games = new List<Game>();

            foreach (XmlNode node in nodes)
            {
                Game game = new Game();

                game.id = node.SelectSingleNode("id").InnerText;
                game.title = node.SelectSingleNode("GameTitle").InnerText;

                games.Add(game);
            }

            Console.WriteLine("The ID is: " + games[0].id);
            Console.WriteLine("The Title of the Game is: " + games[0].title);
            Console.ReadLine();
        }