在Windows Phone 7中使用Syndication Feed和XMLReader读取RSS

问题描述:

嗨我想在Windows Phone中阅读以下Rss。我可以阅读Syndication Feed等常见项目。但我无法从中读取这些元素。我也试过一些代码。但他们没有工作。这是RSS。在Windows Phone 7中使用Syndication Feed和XMLReader读取RSS

<title>Title of the feed </title> 
<pubDate>Thu, 22 Nov 2010 22:15:04 +0000</pubDate> 
<guid isPermaLink="false"><![CDATA[2c864c4ffasfasfasfasfaer54854738422711]]></guid> 
<link><![CDATA[http://abc.ldfan.com/something something something]]></link> 
<media:thumbnail url="http://abc.ldfan.com/item/2137111" /> 
<description><![CDATA[<p>some descriptions jsdfoasjf saifjoeij alfoer alfmaoeijfea9 a epfa3- fasfa039ur aelmf320jaofa </p>]]></description> 
<enclosure length="9113657" type="audio/mpeg" url="http://abc.ldfan.com/eslasdfast/song.mp3" /> 
<itunes:duration>12:39</itunes:duration> 
<itunes:explicit>no</itunes:explicit> 
<itunes:keywords /> 
<itunes:subtitle><![CDATA[ome descriptions jsdfoasjf saifjoeij alfoer alfmaoeijfea9 a epfa3- fasfa039ur aelmf320jaofa ]]></itunes:subtitle> 

任何帮助,将不胜感激。谢谢。

+0

什么代码可以读取Feed的标题? – gregstoll

+0

foreach(SyndicationItem f in feeds.Items) {string title = f.Title;} –

你想要得到什么样的财产?望着SyndicationItem documentation,拿东西的标准(如pubdate的),你可以使用

foreach (SyndicationItem f in feeds.Items) 
{ 
    DateTime pubDate = f.PublishDate; 
} 

和一些非标准(如iTunes:字幕),你可以使用

foreach (SyndicationItem f in feeds.Items) 
{ 
    string subtitle = f.AttributeExtensions[new XmlQualifiedName("subtitle", "itunes")]; 
} 

又见Loosely-Typed Extensions Sample

+0

Greg,谢谢你的回答....我会试试这个......再次感谢 –

+0

不客气! Upvotes赞赏:-) – gregstoll

+0

格雷格,我不知道原因,但它没有奏效。我在链接中也尝试了一些例子。但没有运气。我根据你的第二个绳索块试图获得扩展。但它提示我处理“KeyNotFound”异常,当我处理它时,它没有找到该键......任何想法? –