This sample C# program demonstrates how to create an Atom feed using the Tortuga Atom .NET API.
// Create an Atom Feed in C#
Tortuga.Atom feed = new Tortuga.Atom();
// Initialize the feed.
feed.NewFeed();
feed.SetTopAttr("version","0.3");
feed.SetTopAttr("xml:lang","en");
feed.AddElement("generator","TortugaAtom/1.0");
feed.AddElement("title","My Cool Atom Feed");
feed.AddLink("alternate","http://www.myCoolAtomFeed.com/news","","text/html");
feed.AddElement("tagline","Top Stories");
feed.AddPerson("author","Tortuga Group LLC","","news-feedback@worldwideweb-x.com");
feed.AddElement("copyright","Copyright 2005 Tortuga Group LLC");
feed.AddElementDate("modified",DateTime.Now);
// Build an entry.
Tortuga.Atom entry = new Tortuga.Atom();
// Inialize the object...
entry.NewEntry();
// Build the atom entry
entry.AddElement("title","Tortuga Atom API Released");
entry.AddLink("alternate","http://www.myCoolAtomFeed.com/news/story1.html","","text/html");
entry.AddElement("id","763489562980");
entry.AddElementDate("issued",DateTime.Now);
entry.AddElementDate("modified",DateTime.Now);
entry.AddElementHtml("content","<br><b>This is the HTML content for this story</b><br>");
entry.SetElementAttr("content",0,"type","text/html");
entry.SetElementAttr("content",0,"mode","escaped");
// Add the entry to the feed.
feed.AddEntry(entry.ToXmlString());
// Build another atom entry
entry.NewEntry();
entry.AddElement("title","Tortuga Blogger API Released");
entry.AddLink("alternate","http://www.myCoolAtomFeed.com/news/story2.html","","text/html");
entry.AddElement("id","763489562981");
entry.AddElementDate("issued",DateTime.Now);
entry.AddElementDate("modified",DateTime.Now);
entry.AddElementHtml("content","<br><b>This is the HTML content for the 2nd story</b><br>");
entry.SetElementAttr("content",0,"type","text/html");
entry.SetElementAttr("content",0,"mode","escaped");
// Add the entry to the feed.
feed.AddEntry(entry.ToXmlString());
MessageBox.Show(feed.ToXmlString());
Site Search
Top Download
Wednesday, September 19, 2007
Create an Atom Feed
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment