次のコードを使用して RSS を読んでいます。
var reader = XmlReader.Create(url);
SyndicationFeed.Load(reader);
RSS は次のようになり、タグにエンコードされた文字 (この場合は としてエンコード)が含まれているSyndicationFeed.Load
場合に例外がスローされます。link
å
%C3%A5
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link rel="self" type="application/rss+xml" href="http://example.com/rss" />
<title>My RSS</title>
<description>My RSS</description>
<pubDate>Mon, 04 Jul 2016 08:19:50 +0200</pubDate>
<generator>RSS Generator 1.1</generator>
<link>http://example.com/rss</link>
<item>
<title>A title</title>
<description>A description</description>
<link>http://bl%C3%A5ljus.se</link>
</item>
</channel>
</rss>
例外は次のとおりです。
System.Xml.XmlException: Error in line x position x. An error was encountered when parsing the item's XML. Refer to the inner exception for more details. --->
System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadAlternateLink(XmlReader reader, Uri baseUri)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItemFrom(XmlReader reader, SyndicationItem result, Uri feedBaseUri)
--- End of inner exception stack trace ---
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItemFrom(XmlReader reader, SyndicationItem result, Uri feedBaseUri)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItem(XmlReader reader, SyndicationFeed feed)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItems(XmlReader reader, SyndicationFeed feed, Boolean& areAllItemsRead)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadXml(XmlReader reader, SyndicationFeed result)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadFeed(XmlReader reader)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadFrom(XmlReader reader)
at System.ServiceModel.Syndication.SyndicationFeed.Load[TSyndicationFeed](XmlReader reader)
System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadAlternateLink(XmlReader reader, Uri baseUri)
at System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItemFrom(XmlReader reader, SyndicationItem result, Uri feedBaseUri)
SyndicationFeed
解析エラーを無視するように伝えるために XML をロードするときに渡すことができる設定はありますか? または他の解決策はありますか?