如何开始制作 C# RSS 阅读器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/576267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get started making a C# RSS Reader?
提问by Kredns
I have been wanting to make a RSS reader for a while now (just for fun), but I don't have the slightest idea of where to start. I don't understand anything about RSS. Are there any good tutorials on RSS and how to implement it in an application (not a tutorial on how to make a RSS reader, that would be too easy).
一段时间以来,我一直想做一个 RSS 阅读器(只是为了好玩),但我对从哪里开始一无所知。我对 RSS 一无所知。是否有关于 RSS 以及如何在应用程序中实现它的好的教程(不是关于如何制作 RSS 阅读器的教程,那太简单了)。
采纳答案by Brian
See
看
http://msdn.microsoft.com/en-us/library/bb943474.aspx
http://msdn.microsoft.com/en-us/library/bb943474.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx
http://msdn.microsoft.com/en-us/library/bb943480.aspx
http://msdn.microsoft.com/en-us/library/bb943480.aspx
Basically there is a lot of stuff in the .Net 3.5 framework that does the grunt-work of parsing and representing feeds; it's not hard to write a 30-line app that takes in a feed URL and downloads the feed and prints the title and author of all the items, for example. (Works for RSS 2.0 (not others!) or Atom.)
基本上,.Net 3.5 框架中有很多东西可以完成解析和表示提要的繁重工作;例如,编写一个包含提要 URL 并下载提要并打印所有项目的标题和作者的 30 行应用程序并不难。(适用于 RSS 2.0(不是其他!)或 Atom。)
回答by Marco Bettiolo
You need to work with the RSS XML specification: http://cyber.law.harvard.edu/rss/rss.html
您需要使用 RSS XML 规范:http: //cyber.law.harvard.edu/rss/rss.html
回答by Julien Roncaglia
回答by dance2die
回答by Lee B
RSS itself is really simple. Just an XML description of a channel, and a list of items on that channel (possibly with files attached to each item). Keeping track of updates is a little tricky, and managing encodings and post times/dates is tricky too though. The real nightmare is all the different "interpretations" of the RSS format that different sites use. If you're really writing a feed reader, you might want to start with parsing Atom, as it's a more standardised format, and might get you further faster, with a good design to branch off into RSS from. But really, you should just use an RSS parsing library -- preferably the most compatible one available (but don't pay for an RSS library; they're common enough).
RSS 本身非常简单。只是一个频道的 XML 描述,以及该频道上的项目列表(可能带有附加到每个项目的文件)。跟踪更新有点棘手,但管理编码和发布时间/日期也很棘手。真正的噩梦是不同站点使用的 RSS 格式的所有不同“解释”。如果你真的在写一个提要阅读器,你可能想从解析 Atom 开始,因为它是一种更标准化的格式,并且可能会让你更快,有一个很好的设计来分支到 RSS。但实际上,您应该只使用 RSS 解析库——最好是可用的最兼容的解析库(但不要为 RSS 库付费;它们已经足够常见了)。
回答by Gregory A Beamer
RSS is an XML dialect, so if you know XML, you have part of the problem solved. If you want a start on your project, consider looking at the open source projects already out there:
RSS 是一种 XML 方言,因此如果您了解 XML,您就可以解决部分问题。如果您想开始您的项目,请考虑查看已有的开源项目:
http://www.codeplex.com/site/search?projectSearchText=RSS%20Reader
http://www.codeplex.com/site/search?projectSearchText=RSS%20Reader
CodePlex (above) is a good place to start, as the majority of the projects will be in C#.
CodePlex(上图)是一个很好的起点,因为大多数项目将使用 C#。
回答by scottm
As another poster recommended, the SyndicationFeed class and Argotic are the best alternatives.
正如另一位海报推荐的那样,SyndicationFeed 类和 Argotic 是最好的选择。
If performance is an issue, the SyndicationFeed class will be much better. I benchmarked it as being about 9 times faster than Argotic on my hardware.
如果性能是一个问题,SyndicationFeed 类会好得多。我将其基准测试为在我的硬件上比 Argotic 快约 9 倍。
The problem I've had with the SyndicationFeed class has been its ability to successfully parse any random feed from the 'net. It fails with an XmlException surprisingly often.
我在 SyndicationFeed 类中遇到的问题是它能够成功解析来自 'net. 它经常以 XmlException 异常失败。
For my uses, I'm sticking with Argotic. After all, it is open source, so I can always make changes if I need to.
对于我的用途,我坚持使用 Argotic。毕竟,它是开源的,所以如果需要,我可以随时进行更改。
回答by Jafin
Consider reading the source code for RSS Bandit, which is a C# Winforms (possibly soon WPF) RSS Reader.
考虑阅读RSS Bandit的源代码,它是一个 C# Winforms(可能很快就是 WPF)RSS 阅读器。
You should get some good ideas by just stepping through the application.
通过逐步完成应用程序,您应该会获得一些好主意。
回答by Lukas ?alkauskas
I suggest you use this
我建议你用这个
RSS.NETis an open-source .NET class library for RSS feeds. It provides a reusable object model for parsing and writing RSS feeds. It is fully compatible with RSS versions 0.90, 0.91, 0.92, and 2.0.1, implementing all constructs.
RSS.NET是用于 RSS 提要的开源 .NET 类库。它为解析和编写 RSS 提要提供了一个可重用的对象模型。它与 RSS 版本 0.90、0.91、0.92 和 2.0.1 完全兼容,实现了所有结构。
Since standard syndication feed does not support other versions of rss.
由于标准联合提要不支持其他版本的 rss。
回答by bkingdev
I've been working with RSS quite a bit and have found that ATOM feeds are typically easier to parse using the RssSyndication class. For RSS 2.0 specifications, if the feed is in fact valid, then it's just as easy to load an XDocument from the URI, and parse the data as needed.
我一直在使用 RSS,并且发现使用 RssSyndication 类通常更容易解析 ATOM 提要。对于 RSS 2.0 规范,如果提要实际上有效,那么从 URI 加载 XDocument 并根据需要解析数据同样容易。