Using system. IO;
Using argotic. Syndication;
Rssfeed feed = new rssfeed ();
Feed. Channel. Link = new uri ("http: // localhost ");
Feed. Channel. Title = "simple RSS feed ";
Feed. Channel. Description = "a minimal RSS 2.0 syndication feed .";
Rssitem item = new rssitem ();
Item. Title = "simple RSS item ";
Item. Link = new uri ("http: // localhost/items/simplerssitem. aspx ");
Item. Description = "a minimal RSS channel item .";
Feed. Channel. additem (item );
Using (filestream stream = new filestream ("simplerssfeed. xml", filemode. Create, fileaccess. Write ))
{
Feed. Save (Stream );
}
Example 2:
Using system. IO;
Using argotic. Common;
Using argotic. Syndication;
Rssfeed feed = new rssfeed ();
Feed. Channel. Link = new uri ("http: // localhost ");
Feed. Channel. Title = "Compact RSS feed ";
Feed. Channel. Description = "a minimal and non-indented RSS 2.0 syndication feed .";
Rssitem item = new rssitem ();
Item. Title = "simple RSS item ";
Item. Link = new uri ("http: // localhost/items/simplerssitem. aspx ");
Item. Description = "a minimal RSS channel item .";
Feed. Channel. additem (item );
Using (filestream stream = new filestream ("compactrssfeed. xml", filemode. Create, fileaccess. Write ))
{
Syndicationresourcesavesettings settings = new syndicationresourcesavesettings ();
Settings. minimizeoutputsize = true;
Feed. Save (stream, settings );
}
If the output on the current page is as follows:Code:
Response. contenttype = "application/RSS + XML ";
Syndicationresourcesavesettings settings = new syndicationresourcesavesettings ();
Settings. characterencoding = new utf8encoding (false );
Feed. Save (response. outputstream, settings );
Example of reading:
Using argotic. Extensions. core;
Using argotic. Syndication;
Rssfeed feed = new rssfeed (New uri ("http://example.com/feed.aspx"), "simple extended syndication feed ");
Feed. Channel. Description = "an example of how to generate an extended syndication feed .";
// Create and add iTunes information to feed Channel
Itunessyndicationextension channelextension = new itunessyndicationextension ();
Channelextension. Context. Subtitle = "this feed uses the iTunes syndication extension .";
Channelextension. Context. explicitmaterial = itunesexplicitmaterial. No;
Channelextension. Context. Author = "John Doe ";
Channelextension. Context. Summary = "The argotic syndication framework natively supports the iTunes syndication extension .";
Channelextension. Context. Owner = new itunesowner ("john.doe@example.com", "John Q. Doe ");
Channelextension. Context. Image = new uri ("http://example.com.feed _logo.jpg ");
Channelextension. Context. categories. Add (New itunescategory ("extensions "));
Channelextension. Context. categories. Add (New itunescategory ("ITunes "));
Feed. Channel. addextension (channelextension );
// Create and add iTunes information to channel item
Rssitem item = new rssitem ();
Item. Title = "my extended channel item ";
Item. Link = new uri ("http://example.com/posts/1234 ");
Item. publicationdate = datetime. now;
Rssenclosure enclosure = new rssenclosure (47156978l, "audio/MP3", new uri ("http://example.com/myPodcast.mp3 "));
Item. enclosures. Add (enclosure );
Itunessyndicationextension itemextension = new itunessyndicationextension ();
Itemextension. Context. Author = "Jane Doe ";
Itemextension. Context. Subtitle = "this channel item uses the iTunes syndication extension .";
Itemextension. Context. Summary = "the iTunes syndication extension properties that are used vary based on whether extending the channel or an item ";
Itemextension. Context. Duration = new timespan (1, 2, 13 );
Itemextension. Context. Keywords. Add ("podcast ");
Itemextension. Context. Keywords. Add ("ITunes ");
Item. addextension (itemextension );
Feed. Channel. additem (item );
// Persist extended feed
Using (filestream stream = new filestream ("extendedfeed. RSS. xml", filemode. Create, fileaccess. Write ))
{
Feed. Save (Stream );
}