Exemplo n.º 1
0
        public XmlSports Deserialize(string xmlFeed)
        {
            XmlSports sports = null;

            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlSports));
            StringReader reader = new StringReader(xmlFeed);

            using (reader)
            {
                sports = (XmlSports)serializer.Deserialize(reader);
                reader.Close();
            }

            return(sports);
        }
Exemplo n.º 2
0
        public XmlSport GetExternalData(string url)
        {
            XmlSports xmlSports = null;

            try
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(XmlSports));
                StreamReader  reader       = new StreamReader(WebRequest.Create(url).GetResponse().GetResponseStream());
                xmlSports = (XmlSports)deserializer.Deserialize(reader);
                reader.Close();
            }
            catch (Exception)
            {
                //log
                return(null);
            }

            return(xmlSports.Sport);
        }