合并多个RSS [英] Merging Multiple RSS feeds

查看:264
本文介绍了合并多个RSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的编程与RSS提要请原谅我,如果这听起来像一个非常普遍的问题。

I’m very new to programming with RSS feeds to please forgive me if this sounds like a really general question.

时有可能采取多个RSS来自多个站点提要并将它们合并为单个对象展现给最终用户?

Is it possible to take multiple RSS feeds from multiple sites and combine them as a single object to show to the end user?

例如,我可以把最新的新闻标题从一个网站,最新的博客更新,从一个完全不同的网站,并将它们组合成一个列表,显示用户?

For example, could I take the latest news headlines from one site, the latest blog updates from a totally different site and combine them into a single list to show the user?

我已经看到了这样的问题问过,似乎像它可能的,但轻微的扭曲是我想要让用户补充说,他们从任何来源想要的任何饲料

I have seen this sort of question asked before and it seems like its possible, but the slight twist is I want to let the user add any feed that they want from any source

我要做到这在ASP.NET

I’m looking to do this in ASP.NET

非常感谢!

推荐答案

您可以使用的 SyndicationFeed 与RSS在.net饲料工作。

You can use the SyndicationFeed class to work with RSS feeds in .Net.

您可能想这样做(未经测试):

You probably want to do something like this (untested):

var allItems = new List<SyndicationItem>();

foreach(var feedUrl in whatever) { //In your list of urls
    using(var reader = XmlReader.Create(url))
        allItems.AddRange(SyndicationFeed.Load(reader).Items);
}

var newFeed = new SyndicationFeed(items);

//Do something with newFeed

您应该增加的情况下错误处理的饲料之一,不可用或无效。

You should add error handling in case one of the feeds is unavailable or invalid.

这篇关于合并多个RSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆