我找到了一个很棒的 RSS 阅读器,它只获取图像。
地址:http://www.kunal-chowdhury.com/2011/08/fetching-picasa-images-through-rss-in.html
我无法弄清楚的是如何让该阅读器仅按所需类别过滤和显示提要中的图像。我不打算将该阅读器用于 Picasa。
我使用的 RSS 提要:http://www.zimo.co/feed/
我创建了一个 ObservableCollection
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 提要,您可以获得图像的显式链接,这些图像稍后可以绑定(bind)到 Image
控件。在您的 Feed 中,我看不到明确的图片链接。
关于c# - 按类别过滤图像,RSS 阅读器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10114837/