SyndicationFeed Class

 

Represents a top-level feed object, <feed> in Atom 1.0 and <rss> in RSS 2.0.

Namespace:   System.ServiceModel.Syndication
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System.Object
  System.ServiceModel.Syndication.SyndicationFeed

public class SyndicationFeed

NameDescription
System_CAPS_pubmethodSyndicationFeed()

Initializes a new instance of the SyndicationFeed class.

System_CAPS_pubmethodSyndicationFeed(IEnumerable<SyndicationItem>)

Initializes a new instance of the SyndicationFeed class with the specified collection of SyndicationItem objects.

System_CAPS_pubmethodSyndicationFeed(String, String, Uri)

Initializes a new instance of the SyndicationFeed class with the specified title, description, and Uniform Resource Identifier (URI).

System_CAPS_pubmethodSyndicationFeed(String, String, Uri, IEnumerable<SyndicationItem>)

Initializes a new instance of the SyndicationFeed class with the specified title, description, URI, and collection of SyndicationItem objects.

System_CAPS_pubmethodSyndicationFeed(String, String, Uri, String, DateTimeOffset)

Creates a new instance of the SyndicationFeed class.

System_CAPS_pubmethodSyndicationFeed(String, String, Uri, String, DateTimeOffset, IEnumerable<SyndicationItem>)

Creates a new instance of the SyndicationFeed class.

System_CAPS_protmethodSyndicationFeed(SyndicationFeed, Boolean)

Creates a new instance of the SyndicationFeed class with the specified feed.

NameDescription
System_CAPS_pubpropertyAttributeExtensions

Gets a collection of attribute extensions.

System_CAPS_pubpropertyAuthors

Gets a collection of authors of the feed.

System_CAPS_pubpropertyBaseUri

Gets and sets the base URI for the SyndicationFeed instance.

System_CAPS_pubpropertyCategories

Gets a collection of categories for the feed.

System_CAPS_pubpropertyContributors

Gets a collection of the contributors to the feed.

System_CAPS_pubpropertyCopyright

Gets and sets copyright information for the feed.

System_CAPS_pubpropertyDescription

Gets and sets a description of the feed.

System_CAPS_pubpropertyElementExtensions

Gets the element extensions for the feed.

System_CAPS_pubpropertyGenerator

Gets and sets the generator of the feed.

System_CAPS_pubpropertyId

Gets and sets the ID of the feed.

System_CAPS_pubpropertyImageUrl

Gets and sets the image URL for the feed.

System_CAPS_pubpropertyItems

Gets a collection of the feed items contained in the feed.

System_CAPS_pubpropertyLanguage

Gets and sets the language of the feed.

System_CAPS_pubpropertyLastUpdatedTime

Gets and sets the time the feed was last updated.

System_CAPS_pubpropertyLinks

Gets the links associated with the feed.

System_CAPS_pubpropertyTitle

Gets and sets the title of the feed.

NameDescription
System_CAPS_pubmethodClone(Boolean)

Creates a copy of the SyndicationFeed instance.

System_CAPS_protmethodCreateCategory()

Creates a new SyndicationCategory instance.

System_CAPS_protmethodCreateItem()

Creates a new SyndicationItem instance.

System_CAPS_protmethodCreateLink()

Creates a new SyndicationLink instance.

System_CAPS_protmethodCreatePerson()

Creates a new SyndicationPerson instance.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetAtom10Formatter()

Gets an Atom10FeedFormatter instance.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetRss20Formatter()

Gets an Rss20FeedFormatter instance.

System_CAPS_pubmethodGetRss20Formatter(Boolean)

Gets a new Rss20FeedFormatter instance.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticLoad(XmlReader)

Loads a syndication feed from the specified XML reader.

System_CAPS_pubmethodSystem_CAPS_staticLoad<TSyndicationFeed>(XmlReader)

Loads a SyndicationFeed-derived instance from the specified XmlReader.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSaveAsAtom10(XmlWriter)

Write the syndication feed to the specified XmlWriter in Atom 1.0 format.

System_CAPS_pubmethodSaveAsRss20(XmlWriter)

Write the syndication feed to the specified XmlWriter in RSS 2.0 format.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_protmethodTryParseAttribute(String, String, String, String)

Attempts to parse an attribute extension.

System_CAPS_protmethodTryParseElement(XmlReader, String)

Attempts to parse an element extension.

System_CAPS_protmethodWriteAttributeExtensions(XmlWriter, String)

Writes the attribute extensions to the specified XmlWriter using the specified syndication version.

System_CAPS_protmethodWriteElementExtensions(XmlWriter, String)

Writes the element extensions to the specified XmlWriter using the specified syndication version.

When serialized to Atom 1.0, a SyndicationFeed instance is written to a <feed> element. The following table shows how each property defined in the SyndicationFeed class is serialized to Atom 1.0.

SyndicationFeed property

Serialized form

AttributeExtensions

An attribute in the <feed> element for each attribute in the collection.

Authors

An <author> element for each SyndicationPerson in the collection.

Categories

A <category> element for each SyndicationCategory in the collection.

Contributors

A <contributor> element for each SyndicationPerson in the collection.

Copyright

A <rights> element.

Description

A <subtitle> element.

ElementExtensions

Each element in the collection is written within the <feed> element.

Generator

A <generator> element.

Id

An <id>element.

ImageUri

A <logo> element.

Items

An <entry> element for each SyndicationItem in the collection.

Language

Not serialized.

LastUpdatedTime

An <updated> element.

Links

A <link> element for each SyndicationLink in the collection.

Title

A <title> element.

When serialized to RSS 2.0, a SyndicationFeed instance is written to an <rss> element. The following table shows how each property defined in the SyndicationFeed class is serialized to RSS 2.0.

SyndicationFeed property

Serialized form

AttributeExtensions

An attribute in the <channel> element for each attribute in the collection.

Authors

A <managingEditor> element if only one SyndicationPerson is in the collection; otherwise, an <a10:author> element for each SyndicationPerson in the collection.

Categories

A <category> element for each SyndicationCategory in the collection.

Contributors

An <a10:contributor> element for each SyndicationPerson in the collection.

Copyright

A <copyright> element.

Description

A <description> element.

ElementExtensions

Each element in the collection is written within the <channel> element.

Generator

A <generator> element.

Id

An <a10:id> element.

ImageUri

An <image> element.

Items

An <item> element for each SyndicationItem in the collection.

Language

A <language> element.

LastUpdatedTime

A <lastBuildDate> element.

Links

An <a10:link> element for each SyndicationLink in the collection.

Title

A <title> element.

The following code shows how to create a SyndicationFeed instance and serialize it to both Atom 1.0 and RSS 2.0.

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();

The following XML shows how a SyndicationFeed is serialized to Atom 1.0.

<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>

The following XML shows how a SyndicationFeed instance is serialized to RSS 2.0.

<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>

.NET Framework
Available since 3.5
Silverlight
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: