2016-10-02 19 views
0

私はSyndicationFeedを使用してAtomフィードを生成しています。SyndicationFeedがrel = "self"属性を追加していません

W3C Feed Validation Serviceを使用してフィードを検証する場合を除いて、すべての機能が動作しているようですが、次の警告が表示されます。

このフィードは有効ですが、以下の推奨事項を実装することで、幅広い範囲のフィードリーダーとの相互運用性を向上できます。 行2、列0:欠落しているアトム:REL =「自己」それは私が作成したタグに属性を追加するのは簡単だ

とのリンクが、私はSyndicationFeedを得ることができますどのようにそれを追加するには?私はこれのための設定を見ていないよ。

ここは私のフィードの最初の部分です。

<?xml version="1.0" encoding="UTF-8"?> 
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"> 
    <title type="text">Insider Articles</title> 
    <subtitle type="text">Insider Articles data feed.</subtitle> 
    <id>http://www.insiderarticles.com/Syndication/Atom</id> 
    <rights type="text">Copyright (c) 2016 Insider Articles. All Rights Reserved.</rights> 
    <updated>2016-10-02T12:47:21-07:00</updated> 
    <logo>http://www.insiderarticles.com/Content/Images/rss.jpg</logo> 
    <link rel="alternate" href="http://www.insiderarticles.com/" /> 
    <entry> 
    <!-- Etc... --> 

私のフィード(フィードアイテムを除いたもの)の構成は次のとおりです。

// Construct feed 
SyndicationFeed feed = new SyndicationFeed(
    Properties.Settings.Default.ApplicationName, 
    Properties.Settings.Default.FeedSummary, 
    new Uri(Properties.Settings.Default.ApplicationDomainRoot), 
    string.Format("{0}/Syndication/Atom", Properties.Settings.Default.ApplicationDomainRoot), 
     DateTime.Now); 
    feed.Language = "en-us"; 
    feed.Copyright = new TextSyndicationContent(Properties.Settings.Default.ApplicationCopyright); 
    feed.ImageUrl = new Uri(string.Format("{0}/Content/Images/rss.jpg", uriRoot)); 
    feed.Items = items; 

答えて

0

上記の私のコードは、代替リンク(rel="alternate")を追加したが、バリはまた、(rel="self")も元のフィードへのリンクを望んでいます。

次のコードを追加して問題を修正しました。

string feedUrl = string.Format("{0}/Syndication/Atom", UrlBuilder.GetUriRoot(uri)); 

// Add feed (self) URL 
var link = new SyndicationLink(new Uri(feedUrl)); 
link.RelationshipType = "self"; 
feed.Links.Add(link); 
関連する問題