按类别过滤图像,RSS阅读器
本文关键字:RSS 图像 过滤 | 更新日期: 2023-09-27 18:30:44
我找到了一个很棒的RSS阅读器,它只能获得图像。
位置: http://www.kunal-chowdhury.com/2011/08/fetching-picasa-images-through-rss-in.html
我无法弄清楚的是,如何使该阅读器仅按所需类别过滤和显示提要中的图像。我不打算用这个阅读器来写Picasa。
我使用的RSS提要:http://www.zimo.co/feed/
我创建了一个可观察集合
ObservableCollection<FeedItem> categories;
public ObservableCollection<FeedItem> Categories
{
get { return categories; }
set
{
categories = value;
OnPropertyChanged("Categories");
}
}
并更新了代码,如下所示
private void Feed(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (!e.Cancelled)
{
var xmlElement = XElement.Parse(e.Result);
FeedItems.Clear();
//added code for pulling all categories for every item in the feed
foreach (var katItem in from value
in xmlElement.Elements("channel").Elements("item").Elements("category")
select value.Value
into xCategory
where xCategory != null
select new FeedItem { Category = xCategory })
{
Categories.Add(katItem);
}
foreach (var feedItem in from value
in xmlElement.Elements("channel").Elements("item")
select value.Element("enclosure")
into xEnclosure
where xEnclosure != null
select xEnclosure.Attribute("url")
into xUrl
where xUrl != null
select new FeedItem { Link = xUrl.Value }
)
{
FeedItems.Add(feedItem);
}
}
}
catch
{ }
}
这样,我就有一个集合(类别),其中我从提要中的每个项目获取所有类别。我想知道的事情。是否可以合并这两个集合,然后按所需类别过滤新集合,以便我只获得所需的图像?
您必须自己解析图像。使用 Picasa 源,您可以获得指向图像的显式链接,这些图像稍后可以绑定到 Image
控件。对于您的 Feed,我没有看到露骨的图片链接。