Beispiel #1
0
        static List <HabrNews> GetHabrNews()
        {
            List <HabrNews> habrNewses = new List <HabrNews>();

            foreach (XmlNode item in GetDoc("https://habr.com/ru/rss/interesting/")
                     .SelectNodes("//rss/channel/item"))
            {
                HabrNews hn = new HabrNews();
                hn.title       = item.SelectSingleNode("title").InnerText;
                hn.link        = item.SelectSingleNode("link").InnerText;
                hn.description = item.SelectSingleNode("description").InnerText;
                hn.pubDate     = Convert.ToDateTime(item.SelectSingleNode("pubDate").InnerText);
                habrNewses.Add(hn);
            }

            return(habrNewses);
        }
Beispiel #2
0
        static List <HabrNews> GetHabrNews1()
        {
            List <HabrNews> newses = new List <HabrNews>();

            XmlDocument doc = GetDocument("https://habr.com/ru/rss/interesting/");

            foreach (XmlNode item in doc.SelectNodes("//rss/channel/item"))
            {
                HabrNews habrNews = new HabrNews();
                habrNews.title    = item.SelectSingleNode("title").InnerText;
                habrNews.descript = item.SelectSingleNode("description").InnerText;
                habrNews.link     = item.SelectSingleNode("link").InnerText;
                habrNews.pubDate  = Convert.ToDateTime(item.SelectSingleNode("pubDate").InnerText);
                newses.Add(habrNews);
            }

            return(newses);
        }
Beispiel #3
0
        static List <HabrNews> GetHabrNews()
        {
            List <HabrNews> newses = new List <HabrNews>();

            XmlDocument doc = GetDocument("https://habr.com/ru/rss/interesting/");

            foreach (XmlNode root in doc.DocumentElement.ChildNodes)
            {
                foreach (XmlNode channel in root.ChildNodes)
                {
                    if (channel.Name == "item")
                    {
                        HabrNews habrNews = new HabrNews();
                        foreach (XmlNode itemChannel in channel.ChildNodes)
                        {
                            switch (itemChannel.Name)
                            {
                            case "title":
                                habrNews.title = itemChannel.InnerText;
                                break;

                            case "description":
                                habrNews.descript = itemChannel.InnerText;
                                break;

                            case "link":
                                habrNews.link = itemChannel.InnerText;
                                break;

                            case "pubDate":
                                habrNews.pubDate = Convert.ToDateTime(itemChannel.InnerText);
                                break;
                            }
                        }
                        newses.Add(habrNews);
                    }
                }
            }
            return(newses);
        }