简体   繁体   English

使用asp.net c#解析RSS feed

[英]Parse RSS feed using asp.net c#

I have an RSS feed that I follow and would like to display it on my website. 我有一个RSS订阅源,我想在我的网站上显示它。 The UI would simply contain the description of the article in the RSS feed and also have the link to click on. UI将简单地包含RSS提要中文章的描述,并且还具有要单击的链接。

Since I'm using the ASP.NET C# framework, I'm wondering if this has been done before. 由于我使用的是ASP.NET C#框架,我想知道以前是否已经完成了。

Thanks! 谢谢!

The consumption (and generation) of feeds has been baked into the framework since .NET 3.5 SP1 in the System.ServiceModel.Syndication namespace. System.ServiceModel.Syndication命名空间中的.NET 3.5 SP1以来,已将源的消耗(和生成)添加到框架中。

You can consume a feed (ATOM or RSS) using the SyndicationFeed class, like this: 您可以使用SyndicationFeed类来使用feed(ATOM或RSS),如下所示:

var reader = XmlReader.Create("http://localhost/feeds/serializedFeed.xml");
var feed = SyndicationFeed.Load(reader);

Lots of examples on MSDN - take a look at the namespace page I've linked to. MSDN上的大量示例 - 请查看我链接到的命名空间页面。 Should get you started. 应该让你开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM