Rss20FeedFormatter.WriteTo Method (XmlWriter)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Writes the SyndicationFeed associated with the Rss20FeedFormatter to the specified XmlWriter.

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

public override void WriteTo(
	XmlWriter writer
)

Parameters

writer
Type: System.Xml.XmlWriter

The XmlWriter to write to.

The following code shows how to create a syndication feed and use a Rss20FeedFormatter to write the feed to an XmlWriter.

       SyndicationFeed feed = new SyndicationFeed("Test Feed", "This is a test feed", new Uri("http://Contoso/testfeed"), "TestFeedID", DateTime.Now);
       SyndicationItem item = new SyndicationItem("Test Item", "This is the content for Test Item", new Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now);

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

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

.NET Framework
Available since 3.5
Silverlight
Available since 2.0
Return to top
Show: