当前位置: 首页>>代码示例>>C#>>正文


C# Rss20FeedFormatter.ReadFrom方法代码示例

本文整理汇总了C#中System.ServiceModel.Syndication.Rss20FeedFormatter.ReadFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Rss20FeedFormatter.ReadFrom方法的具体用法?C# Rss20FeedFormatter.ReadFrom怎么用?C# Rss20FeedFormatter.ReadFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Syndication.Rss20FeedFormatter的用法示例。


在下文中一共展示了Rss20FeedFormatter.ReadFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRssFeedItems

 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();
 }
开发者ID:philwith,项目名称:racingresource,代码行数:25,代码来源:RssUtilities.cs

示例2: ParseXml

        /// <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");
            }
        }
开发者ID:mobile32,项目名称:RSS-Reader,代码行数:38,代码来源:Reader.cs

示例3: GetFeeds

        public static IList<Feed> GetFeeds()
        {
            var urls = new[]
                {
                    "http://www.simplyvinay.com/GetBlogRss.aspx", "http://www.bbc.co.uk/blogs/formula1/rss.xml",
                    "http://feeds.feedburner.com/AyendeRahien"
                };
            var list = new List<Feed>();

            foreach (var url in urls)
            {
                using (var reader = new CustomXmlReader(url))
                {
                    if (reader.ReadState == ReadState.Initial)
                        reader.MoveToContent();

                    var atom = new Atom10FeedFormatter();
                    if (atom.CanRead(reader))
                    {
                        atom.ReadFrom(reader);
                        list.AddRange(GenerateFeed(atom.Feed, true));
                    }

                    var rss = new Rss20FeedFormatter();
                    if (rss.CanRead(reader))
                    {
                        rss.ReadFrom(reader);
                        list.AddRange(GenerateFeed(rss.Feed, false));
                    }
                }
            }
            return list;
        }
开发者ID:simplyvinay,项目名称:feedreader,代码行数:33,代码来源:Program.cs

示例4: GetPosts

 public IEnumerable<SyndicationItem> GetPosts(string FeedUrl, int count)
 {
     using (XmlReader reader = XmlReader.Create(FeedUrl))
     {
         Rss20FeedFormatter feedFormatter = new Rss20FeedFormatter();
         feedFormatter.ReadFrom(reader);
         feedFormatter.PreserveElementExtensions = false;
         return feedFormatter.Feed.Items.Take(3);
     }
 }
开发者ID:joymon,项目名称:JoymonOnline.In,代码行数:10,代码来源:BlogDataProvider.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     XmlReader RSSReader = XmlReader.Create(ConfigurationManager.AppSettings["rssUri"]);
     Rss20FeedFormatter formatter = new Rss20FeedFormatter();
     formatter.ReadFrom(RSSReader);
     lblTitle.Text = formatter.Feed.Title.Text;
     lblDescription.Text = formatter.Feed.Description.Text;
     hlRss.NavigateUrl = formatter.Feed.Links[0].Uri.AbsoluteUri;
     lvRSS.DataSource = formatter.Feed.Items;
     lvRSS.DataBind();
 }
开发者ID:cstruter,项目名称:RSS,代码行数:11,代码来源:Example4.aspx.cs

示例6: Research

        public ActionResult Research()
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://blog.firmus-software.co.uk/syndication.axd");

            using (WebResponse response = request.GetResponse())
            {
                using (var reader = new XmlTextReader(response.GetResponseStream()))
                {
                    Rss20FeedFormatter rssFeed = new Rss20FeedFormatter();
                    rssFeed.ReadFrom(reader);
                    return View(rssFeed.Feed);
                }
            }
        }
开发者ID:oclancy,项目名称:FirmusSoftwareLtd,代码行数:14,代码来源:HomeController.cs

示例7: GetFeed

 public Rss20FeedFormatter GetFeed(string feedUrl)
 {
     var formatter = new Rss20FeedFormatter();
     try
     {
         using (var reader = XmlReader.Create(feedUrl))
         {
             formatter.ReadFrom(reader);
         }
     }
     catch (FileNotFoundException ex) { }
     catch (WebException ex) { }
     return formatter;
 }
开发者ID:oleguchok,项目名称:SPP-Labs,代码行数:14,代码来源:FeedService.cs

示例8: IsValidFeedUrl

        // Kontrollerar så att parametern är av rss format.
        public static bool IsValidFeedUrl(string url)
        {
            bool isValid = true;
            try
            {
                XmlReader reader = XmlReader.Create(url);
                Rss20FeedFormatter formatter = new Rss20FeedFormatter();
                formatter.ReadFrom(reader);
                reader.Close();
            }
            catch
            {
                isValid = false;
            }

            return isValid;
        }
开发者ID:psaxin,项目名称:PsJf,代码行数:18,代码来源:validate.cs

示例9: checkURL

        internal static bool checkURL(string url)
        {
            bool URLcheck;

            try {

                XmlReader reader = XmlReader.Create(url);
                Rss20FeedFormatter formatter = new Rss20FeedFormatter();
                formatter.ReadFrom(reader);
                reader.Close();
                URLcheck = true;
            }
            catch{
                Console.WriteLine("URL är felaktig");
                URLcheck = false;
            }

            return URLcheck;
        }
开发者ID:SimonRunnquist,项目名称:FeedMeOru,代码行数:19,代码来源:validate.cs

示例10: LoadFilterFeeds

 protected override SyndicationFeedFormatter LoadFilterFeeds(IEnumerable<string> feedsToLoad,
     IEnumerable<string> filterTags)
 {
     var formatter = new Rss20FeedFormatter();
     var feedItems = new List<SyndicationItem>();
     foreach (var feed in feedsToLoad)
     {
         try
         {
             using (XmlReader reader = XmlReader.Create(feed))
             {
                 formatter.ReadFrom(reader);
                 feedItems.AddRange(formatter.Feed.Items);
             }
         }
         catch (FileNotFoundException ex) { }
         catch (WebException ex) { }
     }
     formatter.Feed.Items = FilterLoadedFeedItems(feedItems, filterTags);
     return formatter;
 }
开发者ID:oleguchok,项目名称:SPP-Labs,代码行数:21,代码来源:ConcreteFeedLoader.cs

示例11: ReadFrom_Feed

		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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:Rss20FeedFormatterTest.cs

示例12: AddURIItems_Click

        // Add URI items
        private void AddURIItems_Click(object sender, EventArgs e)
        {
            imageListView.SuspendLayout();
            string query = "lemur";
            string feedUrl = "http://search.yahooapis.com/ImageSearchService/rss/imageSearch.xml?appid=yahoosearchimagerss&query=" + query;
            using (XmlReader reader = XmlReader.Create(feedUrl))
            {
                Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter();
                rssFormatter.ReadFrom(reader);

                foreach (SyndicationItem rssItem in rssFormatter.Feed.Items)
                {
                    if (rssItem.Links.Count > 0)
                    {
                        // Create a virtual item passing image URL as the item key.
                        string title = rssItem.Title.Text;
                        string link = rssItem.Links[0].Uri.ToString();
                        imageListView.Items.Add(link, title, uriAdaptor);
                    }
                }
            }
            imageListView.ResumeLayout();
        }
开发者ID:Cocotteseb,项目名称:imagelistview,代码行数:24,代码来源:TestForm.cs

示例13: ReadFrom_WrongDate2

		public void ReadFrom_WrongDate2 ()
		{
			Rss20FeedFormatter f = new Rss20FeedFormatter ();
			f.ReadFrom (CreateReader ("<rss version='2.0'><channel><lastBuildDate>2000-01-01T00:00:00</lastBuildDate></rss></channel>"));
		}
开发者ID:nickchal,项目名称:pash,代码行数:5,代码来源:Rss20FeedFormatterTest.cs

示例14: ReadFrom_Docs

		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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:Rss20FeedFormatterTest.cs

示例15: ReadFrom1

		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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:Rss20FeedFormatterTest.cs


注:本文中的System.ServiceModel.Syndication.Rss20FeedFormatter.ReadFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。