示例#1
0
        public static List <SyndicationItem> GetRssFeedItems(string url)
        {
            Rss20FeedFormatter formatter = new Rss20FeedFormatter();
            XmlReader          reader;

            try
            {
                reader = XmlReader.Create(url);
                formatter.ReadFrom(reader);
            }
            catch (XmlException xexp)
            {
                string xml;
                using (WebClient webClient = new WebClient())
                {
                    xml = Encoding.UTF8.GetString(webClient.DownloadData(url));
                }
                xml = xml.Replace("BST", "+0100");
                xml = xml.Replace("GMT", "+0000");
                byte[] bytes = System.Text.UTF8Encoding.ASCII.GetBytes(xml);
                reader = XmlReader.Create(new MemoryStream(bytes));
                formatter.ReadFrom(reader);
            }
            reader.Close();
            return(formatter.Feed == null ? null : formatter.Feed.Items.ToList());
        }
示例#2
0
        public void ReadFrom1()
        {
            Rss20FeedFormatter f = new Rss20FeedFormatter();

            Assert.IsNull(f.Feed, "#1");
            f.ReadFrom(CreateReader("<rss version='2.0'><channel><title>test</title></channel></rss>"));
            SyndicationFeed feed1 = f.Feed;

            Assert.IsNotNull(f.Feed.Title, "#2");
            Assert.AreEqual("test", f.Feed.Title.Text, "#3");
            f.ReadFrom(CreateReader("<rss version='2.0'><channel><title>test</title></channel></rss>"));
            Assert.IsFalse(object.ReferenceEquals(feed1, f.Feed), "#4");
        }
示例#3
0
        public Task <IEnumerable <DashboardBlogDto> > GetBlogAsync(BlogQuery query,
                                                                   CancellationToken token)
        {
            //var blogName = "English";
            //if (country == Country.Israel)
            //{
            //    blogName = "Hebrew";
            //}

            using var reader = XmlReader.Create("https://www.blog.spitball.co/blog-feed.xml");
            var formatter = new Rss20FeedFormatter();

            formatter.ReadFrom(reader);
            var items = formatter.Feed.Items;

            token.ThrowIfCancellationRequested();

            var result = items
                         .Where(w => w.Categories.Any(a => a.Name == query.Category) && w.Categories.Any(a => a.Name == query.BlogName))
                         .Select(s => new DashboardBlogDto
            {
                Image = s.Links.Where(w => w.RelationshipType == "enclosure").Select(s2 => s2.Uri).First()
                        .ChangeToHttps(),
                Url      = s.Links.Where(w => w.RelationshipType == "alternate").Select(s2 => s2.Uri).First(),
                Title    = s.Title.Text,
                Uploader = s.ElementExtensions
                           .ReadElementExtensions <string>("creator", "http://purl.org/dc/elements/1.1/").FirstOrDefault(),
                Create = s.PublishDate
            }).OrderByDescending(o => o.Create).Take(query.Amount);

            return(Task.FromResult(result));
        }
示例#4
0
        protected void ReadRss(object sender, ElapsedEventArgs e)
        {
            Rss20FeedFormatter rssFormatter;
            XmlSerializer      writer = new XmlSerializer(typeof(List <NewsItem>));

            //bool Firstrun = true;

            using (var xmlReader = XmlReader.Create
                                       ("https://www.thenews.com.pk/rss/1/1"))
            {
                rssFormatter = new Rss20FeedFormatter();
                rssFormatter.ReadFrom(xmlReader);
            }
            List <NewsItem> news = new List <NewsItem>();

            foreach (var syndicationItem in rssFormatter.Feed.Items)
            {
                NewsItem newsItem = new NewsItem();
                newsItem.Title         = syndicationItem.Title.Text;
                newsItem.PublishedDate = syndicationItem.PublishDate.ToString();

                //avoid tags
                string description = syndicationItem.Summary.Text;
                description          = Regex.Replace(description, @"<.+?>", "");
                newsItem.Description = WebUtility.HtmlDecode(description);

                newsItem.NewsChannel = rssFormatter.Feed.Title.Text;
                news.Add(newsItem);
            }

            FileStream file = new FileStream(@"C:\Users\Naqib\Documents\Visual Studio 2015\Thenews.xml", FileMode.Create, FileAccess.Write);

            writer.Serialize(file, news);
            file.Close();
        }
示例#5
0
        public RssFeed OnGetFeed(string url)
        {
            try
            {
                RssFeed rssFeed = null;
                using (XmlReader reader = XmlReader.Create(url))
                {
                    var formatter = new Rss20FeedFormatter();
                    formatter.ReadFrom(reader);

                    var DataFeed      = formatter.Feed as SyndicationFeed;
                    var DataFeedItems = formatter.Feed.Items; //{System.ServiceModel.Syndication.SyndicationItem}

                    if (DataFeed != null)
                    {
                        rssFeed = MappingDataFeed(DataFeed);
                    }

                    return(rssFeed);
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                //throw new Exception("File " + url + "not found");
                Log.Write("File " + url + "not found", "DL", "RSS_Reader", "OnGetFeed");
                return(null);
            }
            catch (Exception ex)
            {
                Log.Write(ex.Message, "DL", "RSS_Reader", "OnGetFeed");
                return(null);
            }
        }
示例#6
0
        AtomFeed GenerateAtomFeed(NameValueCollection parameters)
        {
            XmlReader xr;

            var      ff   = new Rss20FeedFormatter();
            AtomFeed feed = null;

            try{
                xr = XmlReader.Create(this.Url);
                ff.ReadFrom(xr);

                feed = new AtomFeed(ff.Feed);
                var count = 0;
                foreach (AtomItem item in feed.Items)
                {
                    item.Content = item.Summary;
                    item.Categories.Add(new SyndicationCategory("rss"));
                    count++;
                }
                feed.TotalResults = count;
                feed.Language     = null;
            } catch (Exception e) {
                return(null);
            }
            return(feed);
        }
示例#7
0
        DataSource ModifyFeed(DataSource datasource)
        {
            try
            {
                Rss20FeedFormatter formatter = new Rss20FeedFormatter();
                formatter.ReadFrom(XmlReader.Create(datasource.inputUri));
                SyndicationFeed feed = formatter.Feed;

                DateTimeOffset itemdate    = datasource.date;
                DateTimeOffset maxitemdate = datasource.date;
                datasource.feed.Title       = feed.Title;
                datasource.feed.Description = feed.Description;

                List <SyndicationItem> items = new List <SyndicationItem>();
                items.AddRange(datasource.feed.Items);
                foreach (SyndicationItem item in feed.Items)
                {
                    if (item.PublishDate > itemdate)
                    {
                        items.Add(item);
                    }
                    if (item.PublishDate > maxitemdate)
                    {
                        maxitemdate = item.PublishDate;
                    }
                }

                //SindicationIntem - это и есть новость
                datasource.feed.Items = items;
                datasource.date       = maxitemdate;
            }
            catch { }

            return(datasource);
        }
示例#8
0
        /// <summary>
        /// Gets the rss feeds.
        /// </summary>
        /// <returns>The rss feeds.</returns>
        /// <param name="context">Context.</param>
        /// <param name="uri">URI.</param>
        public List <RssNews> GetFeeds()
        {
            List <RssNews> result = new List <RssNews>();

            if (!string.IsNullOrEmpty(this.Url))
            {
                var ff = new Rss20FeedFormatter(); // for Atom you can use Atom10FeedFormatter()
                var xr = XmlReader.Create(this.Url);
                ff.ReadFrom(xr);

                AtomFeed feed = new AtomFeed(ff.Feed);
                foreach (AtomItem item in feed.Items)
                {
                    RssNews rss = new RssNews(context);
                    rss.Title   = item.Title.Text;
                    rss.Url     = item.Links[0].Uri.AbsoluteUri;
                    rss.Content = item.Summary.Text;
                    rss.Time    = item.PublishDate.DateTime;
                    if (item.Authors.Count > 0)
                    {
                        rss.Author = item.Authors[0].Name;
                    }
                    result.Add(rss);
                }
            }
            return(result);
        }
示例#9
0
    /// <summary>
    /// Default Page Load Method
    /// </summary>
    /// <param name="sender">Sender of the event.</param>
    /// <param name="e">Event Argument.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            XmlReader reader = XmlReader.Create(BlogSyndicationUrl);

            Rss20FeedFormatter rss = new Rss20FeedFormatter();

            if (reader != null)
            {
                if (rss.CanRead(reader))
                {
                    rss.ReadFrom(reader);

                    SyndicationItem item;
                    item = rss.Feed.Items.First <SyndicationItem>();
                    if (item != null)
                    {
                        this.latestBlogEntryTitle.Text    = item.Title.Text;
                        this.latestBlogEntrySummary.Text  = item.Summary.Text;
                        this.blogLink.NavigateUrl         = item.Id;
                        this.blogFullPostLink.NavigateUrl = item.Id;
                        this.latestBlogPublishTime.Text   = item.PublishDate.DateTime.ToString("dd-MMM-yyyy  HH:mm", CultureInfo.CurrentCulture) + " " + "by" + " " + item.Authors[0].Email;
                    }
                }
            }
        }
        catch (WebException)
        {
            AppSettingsReader appsReader = new AppSettingsReader();
            this.latestBlogEntrySummary.Text = appsReader.GetValue("LatestBlogAccessMessage", typeof(string)).ToString();
            this.blogFullPostLink.Visible    = false;
        }
    }
示例#10
0
        public ActionResult RssPublications()
        {
            List <Post> posts  = new List <Post>();
            string      imgUrl = "";
            XmlReader   reader = XmlReader.Create("https://pikabu.ru/rss.php");
            var         feed   = new Rss20FeedFormatter();

            feed.ReadFrom(reader);
            for (int i = 0; i < 10; i++)
            {
                var  item = feed.Feed.Items.ToList()[i];
                Post post = new Post();
                if (item.Links.Count > 1)
                {
                    imgUrl = item.Links[1].Uri.AbsoluteUri;
                    post.attachedPhoto.Add(imgUrl);
                }
                post.groupName = item.Title.Text;
                if (item.Summary.Text != null)
                {
                    post.postText = item.Summary.Text;
                }
                posts.Add(post);
            }
            ViewBag.news = posts;
            return(View());
        }
示例#11
0
        public RssFeedItem[] GetFeedByKeywords(string urlText, string[] keywords)
        {
            if (!String.IsNullOrEmpty(urlText))
            {
                using (var reader = XmlReader.Create(urlText, new XmlReaderSettings()
                {
                    DtdProcessing = DtdProcessing.Parse
                }))
                {
                    var formatter = new Rss20FeedFormatter();
                    formatter.ReadFrom(reader);

                    List <RssFeedItem> items = new List <RssFeedItem>();
                    foreach (SyndicationItem item in formatter.Feed.Items)
                    {
                        foreach (var keyword in keywords)
                        {
                            if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(item.Title.Text, keyword, CompareOptions.IgnoreCase) >= 0 ||
                                CultureInfo.InvariantCulture.CompareInfo.IndexOf(item.Summary.Text, keyword, CompareOptions.IgnoreCase) >= 0)
                            {
                                items.Add(new RssFeedItem(item.Title.Text, item.Summary.Text, urlText));
                            }
                        }
                    }

                    return(items.ToArray());
                }
            }

            return(Array.Empty <RssFeedItem>());
        }
示例#12
0
        public static IEnumerable <Entity> GetEntitiesFromFeed(string urlFeedLocation)
        {
            if (String.IsNullOrEmpty(urlFeedLocation))
            {
                return(null);
            }

            using (XmlReader reader = XmlReader.Create(urlFeedLocation))
            {
                Atom10FeedFormatter atom = new Atom10FeedFormatter();
                // try to read it as an atom feed
                if (atom.CanRead(reader))
                {
                    atom.ReadFrom(reader);
                    AtomFormatter formatter = new AtomFormatter();
                    return(formatter.GetEntities(urlFeedLocation));
                }

                Rss20FeedFormatter rss = new Rss20FeedFormatter();
                // try reading it as an rss feed
                if (rss.CanRead(reader))
                {
                    rss.ReadFrom(reader);
                    RSSFormater formatter = new RSSFormater();
                    return(formatter.GetEntities(urlFeedLocation));
                }

                //add new custom formatters
            }
            return(null);
        }
        public static void SyndicationFeed_Rss_UriParser()
        {
            // *** SETUP *** \\
            // *** EXECUTE *** \\
            SyndicationFeed feed;

            using (XmlReader reader = XmlReader.Create("TestFeeds/RssSpecCustomParser.xml"))
            {
                var formatter = new Rss20FeedFormatter
                {
                    UriParser = (XmlUriData xmlUriData, out Uri uri) =>
                    {
                        uri = new Uri($"http://value-{xmlUriData.UriString}-kind-{xmlUriData.UriKind}-localName-{xmlUriData.ElementQualifiedName.Name}-ns-{xmlUriData.ElementQualifiedName.Namespace}-end");
                        return(true);
                    }
                };
                formatter.ReadFrom(reader);
                feed = formatter.Feed;
            }

            // *** ASSERT *** \\
            Assert.True(feed != null, "res was null.");
            Assert.Equal(new Uri("http://value-ChannelBase-kind-relativeorabsolute-localName-channel-ns--end"), feed.BaseUri);
            Assert.Equal(new Uri("http://value-ImageUrl-kind-relativeorabsolute-localName-url-ns--end"), feed.ImageUrl);
            Assert.NotNull(feed.Links);
            Assert.Equal(1, feed.Links.Count);
            Assert.Equal(new Uri("http://value-FeedLink-kind-relativeorabsolute-localName-link-ns--end"), feed.Links.First().Uri);

            Assert.True(feed.Items != null, "res.Items was null.");
            Assert.Equal(1, feed.Items.Count());
            Assert.Equal(1, feed.Items.First().Links.Count);
            Assert.Equal(new Uri("http://value-itemlink-kind-relativeorabsolute-localName-link-ns--end"), feed.Items.First().Links.First().Uri);
        }
示例#14
0
        public void Work()
        {
            list = new List <ClassBla>();
            int           i     = 0;
            List <string> sites = new List <string> {
                "https://habr.com/rss/interesting/", "https://keddr.com/feed/"
            };

            foreach (string site in sites)
            {
                Rss20FeedFormatter feedFormatter = new Rss20FeedFormatter();
                XmlReader          rssReader     = XmlReader.Create(site);
                if (feedFormatter.CanRead(rssReader))
                {
                    feedFormatter.ReadFrom(rssReader);
                    var DataContext = feedFormatter.Feed;
                    var feedContent = feedFormatter.Feed.Items;
                    foreach (var el in feedContent)
                    {
                        ClassBla obj = new ClassBla(
                            el.PublishDate.ToString(),
                            el.Id
                            );
                        list.Add(obj);
                    }
                    rssReader.Close();
                }
                ProcessChanged(i += 50);
            }

            WorkCompleted(_cancelled);
            DataSave(true);
        }
示例#15
0
        public void ReadFrom_Versionless()
        {
            Rss20FeedFormatter f = new Rss20FeedFormatter();

            Assert.IsNull(f.Feed, "#1");
            f.ReadFrom(CreateReader("<rss>"));
        }
        static void Main(string[] args)
        {
            Console.Write("Enter the name of the Service Namespace you want to connect to: ");
            string serviceNamespace = Console.ReadLine();

            // WebHttpRelayBinding uses transport security by default
            Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "SyndicationService");

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(serviceUri.ToString());
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            Stream             stream    = response.GetResponseStream();
            XmlReader          reader    = XmlReader.Create(stream);
            Rss20FeedFormatter formatter = new Rss20FeedFormatter();

            formatter.ReadFrom(reader);

            Console.WriteLine("\nThese are the contents of your feed: ");
            Console.WriteLine(" ");
            Console.WriteLine(formatter.Feed.Title.Text);
            foreach (SyndicationItem item in formatter.Feed.Items)
            {
                Console.WriteLine(item.Title.Text + ": " + item.Summary.Text);
            }

            Console.WriteLine("Press [Enter] to exit");
            Console.ReadLine();
        }
示例#17
0
        /// <summary>
        /// Loads the HTTP proxies from RSS feed.
        /// </summary>
        private void LoadHTTPProxiesFromRSSFeed()
        {
            lock (syncRoot)
            {
                using (WebClient wc = new WebClient())
                {
                    wc.Headers.Add("User-Agent", SettingsManager.Instance.settings.HTTPUserAgent);

                    using (XmlReader reader = XmlReader.Create(wc.OpenRead(SettingsManager.Instance.settings.ProxyRSSList)))
                    {
                        // Create a new Rss10FeedFormatter object
                        //Rss10FeedFormatter formatter = new Rss10FeedFormatter ();
                        // TODO mine uses 2.
                        Rss20FeedFormatter formatter = new Rss20FeedFormatter();

                        // Parse the feed!
                        formatter.ReadFrom(reader);

                        foreach (var item in formatter.Feed.Items)
                        {
                            string[] spl = item.Title.Text.Split(':');
                            HTTPProxies.Add(new HTTPProxy {
                                url = spl[0], port = int.Parse(spl[1])
                            });
                        }
                    }
                }
            }
        }
示例#18
0
        public ActionResult Index(string url)
        {
            // Send request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "GET";

            // Get response
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            // Read Feed
            XmlReader          xmlReader = XmlReader.Create(response.GetResponseStream());
            Rss20FeedFormatter ff        = new Rss20FeedFormatter();

            ff.ReadFrom(xmlReader);

            List <SyndicationItem>   items   = ff.Feed.Items.ToList();
            List <BESyndicationItem> beItems = new List <BESyndicationItem>();

            for (int i = 0; i < items.Count; i++)
            {
                beItems.Add(new BESyndicationItem(items[i]));
            }

            xmlReader.Close();

            response.GetResponseStream().Close();
            response.Close();

            return(View("RssTree", beItems));
        }
示例#19
0
        /// <summary>
        /// Wybiera stronę na podstawie adresu url i zapisuje wszystkie wiadomości w kolekcji
        /// </summary>
        /// <param name="lineNews">Lista wiadomości</param>
        /// <param name="category">Kategoria źródłowa do odczytu</param>
        public void ParseXml(ObservableCollection <News> lineNews, Category category)
        {
            try
            {
                using (XmlReader reader = XmlReader.Create(category.Url))
                {
                    var formatter = new Rss20FeedFormatter();
                    formatter.ReadFrom(reader);
                    foreach (var item in formatter.Feed.Items)
                    {
                        lineNews.Add(new News
                        {
                            Title       = item.Title.Text,
                            Date        = item.PublishDate.DateTime.ToString(),
                            UrlNews     = item.Links.First().Uri.ToString(),
                            Description = item.Summary.Text,
                            Category    = category.Name,
                            Id          = item.Id
                        });

                        if (item.Links.Count > 1 && item.Links.Any(n => n.Uri.ToString().Contains(".jpg")))
                        {
                            lineNews.Last().UrlImage = item.Links[1].Uri.ToString();
                        }

                        ParseId(lineNews.Last());
                        ParseDescription(lineNews.Last());
                    }
                }
            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message, "Syndication Reader");
            }
        }
示例#20
0
        public static void SyndicationFeed_Rss_UriParser()
        {
            // *** SETUP *** \\
            // *** EXECUTE *** \\
            SyndicationFeed feed;

            using (XmlReader reader = XmlReader.Create(@"RssSpecCustomParser.xml"))
            {
                var formatter = new Rss20FeedFormatter
                {
                    UriParser = (value, kind, localName, ns) => new Uri($"http://value-{value}-kind-{kind}-localName-{localName}-ns-{ns}-end")
                };
                formatter.ReadFrom(reader);
                feed = formatter.Feed;
            }

            // *** ASSERT *** \\
            Assert.True(feed != null, "res was null.");
            Assert.Equal(new Uri("http://value-ChannelBase-kind-relativeorabsolute-localName-channel-ns--end"), feed.BaseUri);
            Assert.Equal(new Uri("http://value-ImageUrl-kind-relativeorabsolute-localName-url-ns--end"), feed.ImageUrl);
            Assert.NotNull(feed.Links);
            Assert.Equal(1, feed.Links.Count);
            Assert.Equal(new Uri("http://value-FeedLink-kind-relativeorabsolute-localName-link-ns--end"), feed.Links.First().Uri);

            Assert.True(feed.Items != null, "res.Items was null.");
            Assert.Equal(1, feed.Items.Count());
            Assert.Equal(1, feed.Items.First().Links.Count);
            Assert.Equal(new Uri("http://value-itemlink-kind-relativeorabsolute-localName-link-ns--end"), feed.Items.First().Links.First().Uri);
        }
示例#21
0
        public static Rss20FeedFormatter formatter3()
        {
            XmlReader reader    = XmlReader.Create("http://pogoda.by/rss2/cityrss.php?q=27612");
            var       formatter = new Rss20FeedFormatter();

            formatter.ReadFrom(reader);
            return(formatter);
        }
示例#22
0
        public static Rss20FeedFormatter formatter2()
        {
            XmlReader reader    = XmlReader.Create("http://nnmclub.to/forum/rssp.xml");
            var       formatter = new Rss20FeedFormatter();

            formatter.ReadFrom(reader);
            return(formatter);
        }
示例#23
0
        public void ReadFrom_Feed()
        {
            string feed =
                @"<rss version=""2.0"" xmlns:a10=""http://www.w3.org/2005/Atom""><channel><title>My Blog Feed</title><link>http://someuri/</link><description>This is a how to sample that demonstrates how to expose a feed using RSS with WCF</description><managingEditor>[email protected]</managingEditor><category>How To Sample Code</category><item><guid isPermaLink=""false"">ItemOneID</guid><link>http://localhost/Content/One</link><title>Item One</title><description>This is the content for item one</description><a10:updated>2008-06-02T10:13:13+03:00</a10:updated></item><item><guid isPermaLink=""false"">ItemTwoID</guid><link>http://localhost/Content/Two</link><title>Item Two</title><description>This is the content for item two</description><a10:updated>2008-06-02T10:13:13+03:00</a10:updated></item><item><guid isPermaLink=""false"">ItemThreeID</guid><link>http://localhost/Content/three</link><title>Item Three</title><description>This is the content for item three</description><a10:updated>2008-06-02T10:13:13+03:00</a10:updated></item></channel></rss>";
            Rss20FeedFormatter f = new Rss20FeedFormatter();

            f.ReadFrom(CreateReader(feed));
            Assert.IsNotNull(f.Feed, "#1");
        }
        private static Rss20FeedFormatter LoadFeedFromUrl(string feedUrl)
        {
            var rssFeedFormatter = new Rss20FeedFormatter();

            using var xmlReader = XmlReader.Create(feedUrl);
            rssFeedFormatter.ReadFrom(xmlReader);

            return(rssFeedFormatter);
        }
示例#25
0
        public void ReadFrom_Docs()
        {
            Rss20FeedFormatter f = new Rss20FeedFormatter();

            f.ReadFrom(CreateReader("<rss version='2.0'><channel><docs>documents</docs></channel></rss>"));
            Assert.IsNotNull(f.Feed, "#1");
            // 'docs' is treated as extensions ...
            Assert.AreEqual(1, f.Feed.ElementExtensions.Count, "#2");
        }
示例#26
0
        public static void Snippet13()
        {
            // <Snippet13>
            XmlReader          rssReader    = XmlReader.Create("http://contoso/Feeds/RSS/MyFeed");
            Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter();

            rssFormatter.ReadFrom(rssReader);
            rssReader.Close();
            // </Snippet13>
        }
示例#27
0
        public static void Snippet14()
        {
            // <Snippet14>
            Rss20FeedFormatter myFeedRssFormatter = new Rss20FeedFormatter(typeof(MySyndicationFeed));
            XmlReader          rssReader          = XmlReader.Create("http://Contoso/Feeds/MyFeed");

            myFeedRssFormatter.ReadFrom(rssReader);
            rssReader.Close();
            // </Snippet14>
        }
示例#28
0
        private static void ValidateRSS(string content)
        {
            Rss20FeedFormatter feedFormatter = new Rss20FeedFormatter();
            XmlReader          rssReader     = XmlReader.Create(new StringReader(content));

            if (feedFormatter.CanRead(rssReader))
            {
                feedFormatter.ReadFrom(rssReader);
                rssReader.Close();
            }
        }
示例#29
0
 public static SyndicationFeed GetFeed(string uri, string timeFormat = "")
 {
     if (!string.IsNullOrEmpty(uri))
     {
         var ff = new Rss20FeedFormatter(); // for Atom you can use Atom10FeedFormatter()
         var xr = new MyXmlReader(uri, timeFormat);
         ff.ReadFrom(xr);
         return(ff.Feed);
     }
     return(null);
 }
示例#30
0
        public static SyndicationFeed GetFeed(string uri)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return(null);
            }
            var rssFormatter = new Rss20FeedFormatter();
            var xmlReader    = XmlReader.Create(uri);

            rssFormatter.ReadFrom(xmlReader);
            return(rssFormatter.Feed);
        }