如何使用syndicationFeed从rss中读取图像URL? [英] How to read a image url from a rss with syndicationFeed?
本文介绍了如何使用syndicationFeed从rss中读取图像URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取图片网址?假设标签是
How to get the image url? supposing that the tag is
<media:thumbnail url="http://img.youtube.com/vi/y6_-cLWwEU0/default.jpg" width="120"
height="90" />
在syndicationFeed中使用syndicationItem?
using syndicationItem in syndicationFeed?
我有类似的东西
Stream stream = e.Result;
XmlReader response = XmlReader.Create(stream);
SyndicationFeed feeds = SyndicationFeed.Load(response);
foreach (SyndicationItem ff in feeds.Items)
{
RssItem rssItem = new RssItem(ff.Title.Text, ff.Summary.Text, ff.PublishDate.ToString(), ff.Links[0].Uri.AbsoluteUri, **ff.image?????** );
rssItems.Add(rssItem);
}
任何帮助??
推荐答案
流stream = e.Result;
Stream stream = e.Result;
XmlReader response = XmlReader.Create(stream);
SyndicationFeed feeds = SyndicationFeed.Load(response);
foreach (SyndicationItem item in feeds.Items)
{
if (item.ElementExtensions.Where(p => p.OuterName == "thumbnail").Count() != 0)
{
string imgPath = item.ElementExtensions.Where(p => p.OuterName == "thumbnail").First().GetObject<XElement>().Attribute("url").Value;
MessageBox.Show(imgPath); //use it to show the img in DIV or whereever you wish.
}
}
这篇关于如何使用syndicationFeed从rss中读取图像URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文