私は wp7 アプリを開発しています。これはシンプルな RSS リーダーです。日付、タイトル、説明を復元できます...
しかし、このrss フィードから画像を復元しようとすると、NullReferenceException が発生します...ここで間違った行:
itemRss.Image = new Uri(item.Element("enclosure").Attribute("url").Value);
それで、イメージを回復するための良い指示は何ですか? 前もって感謝します
私は wp7 アプリを開発しています。これはシンプルな RSS リーダーです。日付、タイトル、説明を復元できます...
しかし、このrss フィードから画像を復元しようとすると、NullReferenceException が発生します...ここで間違った行:
itemRss.Image = new Uri(item.Element("enclosure").Attribute("url").Value);
それで、イメージを回復するための良い指示は何ですか? 前もって感謝します
このフィードには「エンクロージャー」要素はありません。
イメージというと、文章に入っているものですか?その場合は、「コンテンツ」要素を使用して HTML を取得し、この回答で既に示した正規表現を使用します。
var reg = new Regex("src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?");
var match=reg.Match(source);
if(match.Success)
{
var encod = match.Groups["imgSrc"].Value;
}
から uri を回復する必要があります<img src="http://www.artdeseduire.com/wp-content/uploads/2012/02/Comment-choisir-son-jean.jpg" alt="Comment choisir son jean Comment choisir son jean simplement et rapidement..." title="Comment choisir son jean" width="207" height="302" class="alignright size-full wp-image-14072" />
。
var reg1 = new Regex("src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?");
var match1 = reg1.Match(source);
if (match1.Success)
{
temp.UrlImage = new Uri(match1.Groups["imgSrc"].Value, UriKind.Absolute);
}