Exemplo n.º 1
0
        public async void getNoticiasPaisUltimas(Inoticias intnoticas)
        {
            HttpResponseMessage rta = await cliente.GetAsync(new Uri(URL_ELPAISULTIMAS));

            String xml = rta.Content.ToString();

            document = XDocument.Parse(xml);
            List <Noticia> noticia = new List <Noticia>();
            Noticia        temp;
            XElement       rss      = document.Element("rss");
            XElement       channel2 = rss.Element("channel");

            for (int i = 0; i < 10; i++)
            {
                XElement item = channel2.Element("item");
                channel2.Element("item").Remove();
                Noticia noticiaw = new Noticia();
                noticiaw.Categoria   = "Todas";
                noticiaw.Descripcion = item.Element("description").Value;
                noticiaw.Titulo      = item.Element("title").Value;
                noticiaw.Fecha       = item.Element("pubDate").Value;
                try
                {
                    noticiaw.Imagen = item.Element("enclosure").Attribute("url").Value;
                }
                catch (Exception e) {
                    noticiaw.Imagen = "Assets/blanco.jpg";
                }
                noticia.Add(noticiaw);
            }
            intnoticas.getNoticias(noticia);
        }
Exemplo n.º 2
0
        public async void getNoticiasMinutosTecnologia(Inoticias intnoticas)
        {
            HttpResponseMessage rta = await cliente.GetAsync(new Uri(URL_20MINUTOSTECNOLOGIA));

            String xml = rta.Content.ToString();

            document = XDocument.Parse(xml);
            List <Noticia> noticia  = new List <Noticia>();
            Noticia        temp     = new Noticia();
            XElement       rss      = document.Element("rss");
            XElement       channel2 = rss.Element("channel");

            for (int i = 0; i < 10; i++)
            {
                XElement item = channel2.Element("item");
                channel2.Element("item").Remove();
                temp.Titulo    = item.Element("title").Value;
                temp.Fecha     = item.Element("pubDate").Value;
                temp.Categoria = "Tecnologia";
                noticia.Add(temp);
            }


            intnoticas.getNoticias(noticia);
        }
Exemplo n.º 3
0
        public async void getNoticiasPaisCiencia(Inoticias intnoticas)
        {
            HttpResponseMessage rta = await cliente.GetAsync(new Uri(URL_ELPAISCIENCIA));

            String xml = rta.Content.ToString();

            document = XDocument.Parse(xml);
            List <Noticia> noticia  = new List <Noticia>();
            Noticia        temp     = new Noticia();
            XElement       rss      = document.Element("rss");
            XElement       channel2 = rss.Element("channel");

            for (int i = 0; i < 10; i++)
            {
                XElement item = channel2.Element("item");
                channel2.Element("item").Remove();
                temp.Descripcion = item.Element("description").Value;
                temp.Titulo      = item.Element("title").Value;
                temp.Fecha       = item.Element("pubDate").Value;
                temp.Imagen      = item.Element("enclosure").Attribute("url").Value;
                temp.Categoria   = "Ciencia";
                noticia.Add(temp);
            }
            intnoticas.getNoticias(noticia);
        }
Exemplo n.º 4
0
        public async void getNoticiasCaracolEconomia(Inoticias intnoticas)
        {
            HttpResponseMessage rta = await cliente.GetAsync(new Uri(URL_CARACOLECONOMIA));

            String xml = rta.Content.ToString();

            document = XDocument.Parse(xml);
            List <Noticia> noticia  = new List <Noticia>();
            Noticia        temp     = new Noticia();
            XElement       rss      = document.Element("rss");
            XElement       channel2 = rss.Element("channel");

            for (int i = 0; i < 10; i++)
            {
                XElement item = channel2.Element("item");
                channel2.Element("item").Remove();
                temp.Descripcion = item.Element("description").Value;
                temp.Titulo      = item.Element("title").Value;
                temp.Fecha       = item.Element("pubDate").Value;
                temp.Categoria   = "Todas";
                noticia.Add(temp);
            }
            intnoticas.getNoticias(noticia);
        }