解析 Atom 响应时出错

Error during parsing of Atom response

我尝试解析来自 Yandex-Fotki(Image Hoster)的 HttpWebRequest。我收到 Atom 格式的响应,但在 SyndicationFeed 中收到错误:名称为 'service' 且命名空间为“http://www.w3.org/2007/app”的元素不是允许的提要格式。

我的代码是:

XmlReader reader = XmlReader.Create(new StringReader(response));
            SyndicationFeed feed = SyndicationFeed.Load(reader);

这是输入(来自站点的响应):

<app:service xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
  <app:workspace>
    <atom:title>packda на Яндекс.Фотках</atom:title>
    <app:collection href="http://api-fotki.yandex.ru/api/users/packda/albums/" id="album-list">
      <atom:title>Все альбомы пользователя packda</atom:title>
      <app:accept>application/atom+xml; type=entry, application/json; type=entry</app:accept>
    </app:collection>
    <app:collection href="http://api-fotki.yandex.ru/api/users/packda/photos/" id="photo-list">
      <atom:title>Все фотографии пользователя packda</atom:title>
      <app:accept>image/*</app:accept>
      <app:categories scheme="http://api-fotki.yandex.ru/api/users/packda/tags/" />
    </app:collection>
    <app:collection href="http://api-fotki.yandex.ru/api/users/packda/tags/" id="tag-list">
      <atom:title>Все теги пользователя packda</atom:title>
      <app:accept />
    </app:collection>
  </app:workspace>
</app:service>

希望你能帮帮我!

SyndicationFeed 只会用 Atom or RSS 联合格式解析 XML。 Yandex-Fotki 网站的响应似乎两者都不是。

好的,我找到了一个东西,也许这就是您要找的东西。如果您在 Web 浏览器中请求 <collection href="http://api..."> 值,您将获得 Atom 联合格式的 XML。

这是您必须用 SyndicationFeed 解析的 XML。因此,您必须检索集合元素的 href 值,获取 XML 并将其加载到 SyndicationFeed 中。要淘汰您可以尝试的集合元素:

使用 XMLReader 读取 DOM 或将其反序列化为自定义 class 或将 XML 加载到数据集中或 LINQ 到 XML.