2012-03-08 12 views
1

私はwp7アプリを開発しています。これはシンプルなRSSリーダーです。このRSSフィードの画像を修復するにはどうすればいいですか?

itemRss.Image = new Uri(item.Element("enclosure").Attribute("url").Value); 
:ここでは...間違ったライン私は...

日付、タイトルと説明を回復することができるよしかし、私はこのrss feedからイメージを回復するしようとすると、私はとNullReferenceExceptionをキャッチ

画像を回復するにはどうすればよいですか?事前に感謝します

答えて

5

このフィードには「エンクロージャ」要素はありません。

イメージを言うとき、それはテキストに含まれているイメージですか?その場合は、「content」要素を使用して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; 
    } 
+0

ありがとうございました。 – Razor

2

あなたは<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" />からURIを静養する必要があります。

   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); 
       } 
関連する問題