c# - 如何恢复此 rss 提要的图像?

标签 c# windows-phone-7 silverlight-4.0 rss-reader

我正在开发一个 wp7 应用程序,它是一个简单的 rss 阅读器。我能够恢复日期、标题和描述...

但是当我尝试从这个 rss feed 恢复图像时,我发现了一个 NullReferenceException...这里是错误的行:

itemRss.Image = new Uri(item.Element("enclosure").Attribute("url").Value);

那么,请问恢复图像的好方法是什么?提前致谢

最佳答案

此提要中没有“附件”元素。

当你说图片的时候,就是包含在文字中的那个?如果是这样,请使用“内容”元素检索 HTML 并使用 the regex that I have already given in this answer .

    var reg = new Regex("src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?");
    var match=reg.Match(source);
    if(match.Success)
    {
      var encod = match.Groups["imgSrc"].Value;
    }

关于c# - 如何恢复此 rss 提要的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9620061/

相关文章:

c# - 如何让我的应用程序等待特定的时间?

C# 随机数生成器陷入循环

c# - 如何检测 mp3 文件何时播放完毕

windows-phone-7 - Pex 是否支持 windows phone 7 单元测试?

windows-phone-7 - WP7 了解用户是否对应用程序进行了评分或评论

c# - 我如何清空列表框内容c#?

具有提升信任和签名证书的 Silverlight 4 OOB 应用程序不会更新?需要重新安装吗?

silverlight-4.0 - Silverlight在“页面刷新”上丢失身份验证

silverlight - Silverlight 4 OOB 应用程序中并不总是引发 MainWindow.Closing 事件

c# - LiteDB 5 System.IO.IOException : The process cannot access the file