2012-11-27 49 views
2

嗨我想在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;} –

回答

0

你想要得到什麼樣的財產?望着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」異常,當我處理它時,它沒有找到該鍵......任何想法? –