如何使用c#.NEt读取windows手机中的rss feed数据?

时间:2013-03-03 17:58:23

标签: c# windows-phone-7 rss

我有以下RSS Feed,它有关于其他RSS Feed的信息,最终会有数据。 当用户选择任何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.ni.dll中发生'System.Reflection.TargetInvocationException'类型的异常,但未在用户代码中处理

1 个答案:

答案 0 :(得分:0)

您的代码(包括xml解析)工作正常,但您的网址指向包含RSS订阅源的html网页,而不是RSS订阅源。

尝试,例如,这个网址。 http://www.espncricinfo.com/rss/content/story/feeds/1.xml取自该页面。