.NET Framework クラス ライブラリ
SyndicationFeed クラス

更新 : 2007 年 11 月

トップレベルのフィード オブジェクトである、Atom 1.0 の <feed> と RSS 2.0 の <rss> を表します。

名前空間 :  System.ServiceModel.Syndication
アセンブリ :  System.ServiceModel.Web (System.ServiceModel.Web.dll 内)
構文

Visual Basic (宣言)
Public Class SyndicationFeed
Visual Basic (使用法)
Dim instance As SyndicationFeed
C#
public class SyndicationFeed
Visual C++
public ref class SyndicationFeed
J#
public class SyndicationFeed
JScript
public class SyndicationFeed
解説

Atom 1.0 にシリアル化する場合、SyndicationFeed インスタンスは <feed> 要素に書き込まれます。次の表は、SyndicationFeed に定義されている各プロパティが Atom 1.0 にシリアル化される方法を示しています。

SyndicationFeed プロパティ

シリアル化された形式

AttributeExtensions

コレクション内の各属性に対する <feed> 要素の属性。

Authors

コレクション内の各 SyndicationPerson に対する <author> 要素。

Categories

コレクション内の各 SyndicationCategory に対する <category> 要素。

Contributors

コレクション内の各 SyndicationPerson に対する <contributor> 要素。

Copyright

<rights> 要素。

Description

<subtitle> 要素。

ElementExtensions

コレクション内の各要素は、<feed> 要素内に書き込まれます。

Generator

<generator> 要素。

Id

<id> 要素。

ImageUri

<logo> 要素。

Items

コレクション内の各 SyndicationItem に対する <entry> 要素。

Language

シリアル化されません。

LastUpdatedTime

<updated> 要素。

Links

コレクション内の各 SyndicationLink に対する <link> 要素。

Title

<title> 要素。

RSS 2.0 にシリアル化する場合、SyndicationFeed インスタンスは <rss> 要素に書き込まれます。次の表は、SyndicationFeed に定義されている各プロパティが RSS 2.0 にシリアル化される方法を示しています。

SyndicationFeed プロパティ

シリアル化された形式

AttributeExtensions

コレクション内の各属性に対する <channel> 要素の属性。

Authors

コレクション内に SyndicationPerson が 1 つしかない場合は <managingEditor> 要素、それ以外の場合は、コレクション内の各 SyndicationPerson に対する <a10:author> 要素。

Categories

コレクション内の各 SyndicationCategory に対する <category> 要素。

Contributors

コレクション内の各 SyndicationPerson に対する <a10:contributor> 要素。

Copyright

<copyright> 要素。

Description

<description> 要素。

ElementExtensions

コレクション内の各要素は、<channel> 要素内に書き込まれます。

Generator

<generator> 要素。

Id

<a10:id> 要素。

ImageUri

<image> 要素。

Items

コレクション内の各 SyndicationItem に対する <item> 要素。

Language

<language> 要素。

LastUpdatedTime

<lastBuildDate> 要素。

Links

コレクション内の各 SyndicationLink に対する <a10:link> 要素。

Title

<title> 要素。


SyndicationFeed インスタンスを作成し、Atom 1.0 と RSS 2.0 の両方にシリアル化する方法を次のコードに示します。

C#
SyndicationFeed feed = new SyndicationFeed("Feed Title", "Feed Description", new Uri("http://Feed/Alternate/Link"), "FeedID", DateTime.Now);
// Add a custom attribute.
XmlQualifiedName xqName = new XmlQualifiedName("CustomAttribute");
feed.AttributeExtensions.Add(xqName, "Value");

SyndicationPerson sp = new SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http://Jesper/Aaberg");
feed.Authors.Add(sp);

SyndicationCategory category = new SyndicationCategory("FeedCategory", "CategoryScheme", "CategoryLabel");
feed.Categories.Add(category);

feed.Contributors.Add(new SyndicationPerson("lene@contoso.com", "Lene Aaling", "http://lene/aaling"));
feed.Copyright = new TextSyndicationContent("Copyright 2007");
feed.Description = new TextSyndicationContent("This is a sample feed");

// Add a custom element.
XmlDocument doc = new XmlDocument();
XmlElement feedElement = doc.CreateElement("CustomElement");
feedElement.InnerText = "Some text";
feed.ElementExtensions.Add(feedElement);

feed.Generator = "Sample Code";
feed.Id = "FeedID";
feed.ImageUrl = new Uri("http://server/image.jpg");

TextSyndicationContent textContent = new TextSyndicationContent("Some text content");
SyndicationItem item = new SyndicationItem("Item Title", textContent, new Uri("http://server/items"), "ItemID", DateTime.Now);

List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;

feed.Language = "en-us";
feed.LastUpdatedTime = DateTime.Now;

SyndicationLink link = new SyndicationLink(new Uri("http://server/link"), "alternate", "Link Title", "text/html", 1000);
feed.Links.Add(link);

XmlWriter atomWriter = XmlWriter.Create("atom.xml");
Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();

XmlWriter rssWriter = XmlWriter.Create("rss.xml");
Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
rssFormatter.WriteTo(rssWriter);
rssWriter.Close();

SyndicationFeed を Atom 1.0 にシリアル化する方法を次の XML に示します。

xml
<feed xml:lang="en-us" CustomAttribute="Value" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Feed Title</title>
  <subtitle type="text">This is a sample feed</subtitle>
  <id>FeedID</id>

  <rights type="text">Copyright 2007</rights>
  <updated>2007-04-13T17:29:38Z</updated>
  <category term="FeedCategory" label="CategoryLabel" scheme="CategoryScheme" />
  <logo>http://contoso/image.jpg</logo>
  <author>
    <name>Jesper Aaberg</name>
    <uri>http://contoso/Aaberg</uri>
    <email>Jesper.Asberg@contoso.com</email>
  </author>
  <contributor>
    <name>Lene Aalling</name>
    <uri>http://contoso/Aalling</uri>
    <email>Lene.Aaling@contoso.com</email>
  </contributor>
  <generator>Sample Code</generator>
  <link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />

  <link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
  <CustomElement xmlns="">Some text</CustomElement>
  <entry>
    <id>ItemID</id>
    <title type="text">Item Title</title>
    <updated>2007-04-13T17:29:38Z</updated>
    <link rel="alternate" href="http://contoso/items" />
    <content type="text">Some text content</content>
  </entry>

</feed>

SyndicationFeed インスタンスを RSS 2.0 にシリアル化する方法を次の XML に示します。

xml
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel CustomAttribute="Value">
    <title>Feed Title</title>
    <link>http://feed/Alternate/Link</link>
    <description>This is a sample feed</description>
    <language>en-us</language>

    <copyright>Copyright 2007</copyright>

    <managingEditor>Jesper.Aaberg@contoso.com</managingEditor>
    <lastBuildDate>Fri, 13 Apr 2007 17:29:38 Z</lastBuildDate>
    <category domain="CategoryScheme">FeedCategory</category>
    <a10:link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
    <generator>Sample Code</generator>

    <a10:contributor>
      <a10:name>Lene Aalling</a10:name>
      <a10:uri>http://contoso/Aalling</a10:uri>
      <a10:email>Lene.Aalling@contoso.com</a10:email>
    </a10:contributor>

    <a10:author>
      <a10:name>Lene Aalling</a10:name>
      <a10:uri>http://contoso/Aalling</a10:uri>
      <a10:email>Lene.Aalling@contoso.com</a10:email>
    </a10:author>
    <image>
      <url>http://contoso/image.jpg</url>
      <title>Feed Title</title>
      <link>http://feed/Alternate/Link</link>
    </image>
    <a10:id>FeedID</a10:id>
    <a10:link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />

    <CustomElement>Some text</CustomElement>
    <item>
      <guid isPermaLink="false">ItemID</guid>
      <link>http://contoso/items</link>
      <title>Item Title</title>
      <description>Some text content</description>
      <a10:updated>2007-04-13T17:29:38Z</a10:updated>
    </item>
  </channel>
</rss>
継承階層

System..::.Object
  System.ServiceModel.Syndication..::.SyndicationFeed
スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報

.NET Framework

サポート対象 : 3.5
参照

参照

タグ :


Page view tracker