[英]Error during parsing of Atom response
I try to parse a HttpWebRequest from Yandex-Fotki (Image Hoster). 我尝试从Yandex-Fotki(Image Hoster)解析HttpWebRequest。 I get a response in Atom-Format, but in SyndicationFeed I get an error: The element with name 'service' and namespace ' http://www.w3.org/2007/app ' is not an allowed feed format.
我收到Atom格式的响应,但是在SyndicationFeed中收到一个错误: 名称为'service'和名称空间为' http://www.w3.org/2007/app '的元素不是允许的提要格式。
My Code is: 我的代码是:
XmlReader reader = XmlReader.Create(new StringReader(response));
SyndicationFeed feed = SyndicationFeed.Load(reader);
Here is the input(response from the site): 这是输入(来自站点的响应):
<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>
I hope you can help me! 我希望你能帮帮我!
SyndicationFeed
will only parse XML with Atom or RSS Syndication Format. SyndicationFeed
将仅解析具有Atom或RSS Syndication Format的XML。 The response of the site Yandex-Fotki doesn't seem to be neither. Yandex-Fotki网站的响应似乎也不是。
Ok, I found a thing that maybe it is what you are looking for. 好的,我发现可能是您要寻找的东西。 If you do a request in your webbrowser of a
<collection href="http://api...">
value you get a XML in Atom Syndication format. 如果您在Web浏览器中发出
<collection href="http://api...">
值的请求,您将获得Atom Syndication格式的XML。
This is the XML you have to parse with SyndicationFeed
. 这是您必须使用
SyndicationFeed
解析的XML。 So, you have to retrieve the href value of collection elements, get that XML and load it in SyndicationFeed. 因此,您必须检索collection元素的href值,获取该XML并将其加载到SyndicationFeed中。 To retireve the collection elements you can try:
要收回收集元素,您可以尝试:
Read DOM with XMLReader OR Deserilize it to a custom class OR Load XML into a DataSet OR LINQ to XML. 使用XMLReader读取DOM或将其反序列化为自定义类,或者将XML加载到数据集中或LINQ to XML。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.