Partager via


Rss20FeedFormatter.WriteTo(XmlWriter) Méthode

Définition

Écrit le SyndicationFeed associé au Rss20FeedFormatter dans l’objet XmlWriter spécifié.

public:
 override void WriteTo(System::Xml::XmlWriter ^ writer);
public override void WriteTo (System.Xml.XmlWriter writer);
override this.WriteTo : System.Xml.XmlWriter -> unit
Public Overrides Sub WriteTo (writer As XmlWriter)

Paramètres

writer
XmlWriter

XmlWriter dans lequel écrire.

Exemples

Le code suivant illustre la création d'un flux de syndication et l'utilisation d'un module Rss20FeedFormatter pour écrire le flux dans un objet 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();
Dim feed As SyndicationFeed = New SyndicationFeed("Test Feed", "This is a test feed", New Uri("http://Contoso/testfeed"), "TestFeedID", DateTime.Now)
Dim item As SyndicationItem = New SyndicationItem("Test Item", "This is the content for Test Item", New Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now)

Dim items As List(Of SyndicationItem) = New List(Of SyndicationItem)()
items.Add(item)
feed.Items = items

Dim rssWriter As XmlWriter = XmlWriter.Create("RSS.xml")
Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed)
rssFormatter.WriteTo(rssWriter)
rssWriter.Close()

S’applique à