如何使用syndicationFeed从rss中读取图像URL?

如何获取图片url? 假设标签是

 

在syndicationFeed中使用syndicationItem?

我有类似的东西

  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); } 

任何帮助?

溪流= 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().Attribute("url").Value; MessageBox.Show(imgPath); //use it to show the img in DIV or whereever you wish. } } 

我还需要一个解决方案,我这样使用:

 foreach (SyndicationItem item in feed.Items) { int s,f; s = item.Summary.Text.IndexOf("<"); f = item.Summary.Text.IndexOf("/>"); if (f != -1) div1.InnerHtml += "photo:" + item.Summary.Text.Substring(s, f + 1 - s); } 

我从摘要中提取img;

例如,Google RSS将所有图像保存在一个总结中。

所以你可以通过这段代码提取它:

 List rssItems = new List(); Stream stream = e.Result; XmlReader response = XmlReader.Create(stream); SyndicationFeed feeds = SyndicationFeed.Load(response); foreach (SyndicationItem f in feeds.Items) { RssFeedItem rssItem = new RssFeedItem(); rssItem.Description = f.Summary.Text; const string rx = @"(?<=img\s+src\=[\x27\x22])(?[^\x27\x22]*)(?=[\x27\x22])"; foreach (Match m in Regex.Matches(f.Summary.Text, rx, RegexOptions.IgnoreCase | RegexOptions.Multiline)) { string src = m.Groups[1].Value; if (src.StartsWith("//")) // Google RSS has it { src = src.Replace("//", "http://"); } rssItem.ImageLinks.Add(src); }