0

次の RSS フィードがあり、他の RSS フィードに関する情報があり、最終的にはデータがあります。ユーザーがRSSフィードを選択すると(ルートRSSフィードの子RSSフィードを名前で表示したい)、選択したRSSフィードに関する情報が表示されます。

http://www.espncricinfo.com/ci/content/rss/feeds_rss_cricket.html

 public static void Read(string url)
    {
        WebClient webClient = new WebClient();
        webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
        webClient.DownloadStringAsync(new Uri( url));            
    }

 static void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        XDocument document = XDocument.Parse(e.Result);

        //return (from descendant in document.Descendants("item")
        //        select new RssNews()
        //        {
        //            Description = descendant.Element("description").Value,
        //            Title = descendant.Element("title").Value,
        //            PublicationDate = descendant.Element("pubDate").Value
        //        }).ToList();
    }

以下のコードを試しましたが、例外が表示されます。これを修正する方法はありますか?

タイプ 'System.Reflection.TargetInvocationException' の例外が System.ni.dll で発生しましたが、ユーザー コードでは処理されませんでした

4

1 に答える 1

0

コード (xml 解析を含む) は正常に動作しますが、 URL は、RSS フィードではなく、RSS フィードの URL を含む html ページを指しています。

たとえば、この URL を試してください。そのページから取られたhttp://www.espncricinfo.com/rss/content/story/feeds/1.xml 。

于 2013-03-03T18:06:26.363 に答える