Пример #1
0
        public ActionResult Index()
        {
            var nbaplayer = new NBAPlayer()
            {
                Name = "Gilbert Arenas"
            };

            return(View(nbaplayer));
        }
Пример #2
0
        public void ParseDataNBA_Stats()
        {
            StringBuilder output = new StringBuilder();

            string xmlString = streamReader.ReadToEnd();
            streamReader.Close();
            responseStream.Close();
            response.Close();
            int playerCount = 0;
            bool onceOver = false;
            using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
            {
                while (reader.Read())
                {
                    if (onceOver)
                        continue;
                    string temp = "";
                    while (temp != teamName)
                    {
                        reader.ReadToFollowing("Team");
                        reader.ReadToFollowing("name");
                        temp = reader.ReadElementContentAsString();
                    }

                    onceOver = true;
                    for(int i =0; i < 20; i++)
                    {
                        players[playerCount] = new NBAPlayer();
                        reader.ReadToFollowing("Player");
                        reader.ReadToFollowing("Name");
                        players[playerCount].teamName = temp;
                        players[playerCount].name = reader.ReadElementContentAsString();

                        reader.ReadToFollowing("Stat");
                        reader.ReadToFollowing("Stat");
                        reader.ReadToFollowing("Stat");
                        reader.MoveToAttribute("birth_date");
                        players[playerCount].birthData = reader.ReadElementContentAsString();

                        reader.ReadToFollowing("Stat");
                        players[playerCount].weight = reader.ReadElementContentAsInt();

                        reader.ReadToFollowing("Stat");
                        reader.ReadToFollowing("Stat");
                        players[playerCount].height = reader.ReadElementContentAsInt();

                        reader.ReadToFollowing("Stat");
                        players[playerCount].number = reader.ReadElementContentAsInt();

                        playerCount++;

                    }
                }
            }
        }