【问题标题】:Reading RSS with Syndication Feed and XMLReader in Windows Phone 7在 Windows Phone 7 中使用 Syndication Feed 和 XMLReader 读取 RSS
【发布时间】:2012-11-27 02:24:35
【问题描述】:

您好,我想在 Windows Phone 中阅读以下 Rss。我可以使用 Syndication Feed 阅读常见项目,例如标题。但我无法从中读取元素。我也尝试了一些代码。但他们没有工作。这是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>

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

【问题讨论】:

  • 什么代码可以读取提要的标题?
  • foreach (SyndicationItem f in feeds.Items) { string title = f.Title;}

标签: .net rss windows-phone xmlreader syndication-feed


【解决方案1】:

你想得到什么属性?查看SyndicationItem documentation,要获得标准的东西(如pubDate),您可以使用

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

对于非标准的东西(如 itunes:subtitle),您可以使用

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

另请参阅Loosely-Typed Extensions Sample

【讨论】:

  • 格雷格,我不知道原因,但它不起作用。我也在链接中尝试了一些示例。但没有运气。我试着根据你的第二个线块来获得扩展。但它提示我处理“KeyNotFound”异常,当我处理它时,它给了我找不到密钥......有什么想法吗?
  • 你能发布完整的 RSS 文件吗? “itunes”命名空间可能被定义为上面的其他内容,这就是您应该将其用作 XmlQualifiedName 构造函数的第二个参数。
  • @gregstoll 感谢您提供这方面的指导。我认为你想要“ElementExtensions”而不是“AttributeExtesions”。
  • 另外,仅供参考,如果你想获取 itunes 标签,命名空间是 http://www.itunes.com/dtds/podcast-1.0.dtd
猜你喜欢
  • 1970-01-01
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 2011-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多