ASP.NET Tip: Creating an Atom XML Feed

An easy way to promote your site and to attract more visitors is to provide a news feed. Feeds can be read by a variety of programs, including FeedDemon, Mozilla, and the upcoming Internet Explorer 7.0. Many sites continue to use RSS (Real Simple Syndication), but RSS was never a defined standard. Atom, the replacement for RSS, is quickly being adopted by many of the blogging software makers, although most of them still provide support for RSS as well.

This tip shows you how to produce an Atom XML feed using a database table. It is based on the following sample of the Atom syndication format, which is available on this page:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">

   <title>Example Feed</title>
   <link href=""/>
      <name>John Doe</name>

      <title>Atom-Powered Robots Run Amok</title>
      <link href=""/>
      <summary>Some text.</summary>


The entry tag section is the one that will repeat for each article you want to syndicate. Most of the information is fairly self-explanatory, and the site provides other tags that let you further document your articles. A few of these tags may require a bit of coding on your part, however.

The first tag you see is the updated tag, which shows the time in the standard Internet format. The format shows "Zulu" time, which is a military/aviation name for Greenwich Mean Time. Although you could manually create this format, some built-in date/time formats will get you most of the way to there.

The first format string is a lowercase s, which generates the date and time in this format:


The second option is a lowercase u, which generates the date and time in this format:

2000-08-17 23:32:32Z

The second option also translates the local time to the "universal" time. Because you need both the T and the Z, as well as the timezone conversion, you can use the ToUniversalTime method of the DateTime class, the lowercase s format, and simply append a Z to the string. (You can learn more about the various built-in time/date formats by looking at the ToString method of the DateTime class in the MSDN documentation.)

The next tag is the ID tag on both the feed and the entry levels. This is easy to create in .NET by using a globally unique identifier (GUID). The important thing to remember is that this unique value should persist for this entry, meaning that you can't just generate random ones each time you display the feed. In my case, I store the unique identifier in the database so it always displays the same value. If you don't do that, it will cause the various newsreaders to display changes to an article as a new article, which defeats the purpose of sending a feed. If you keep the same ID, the newsreader will usually just indicate that the article has changed but not create a new entry.

Here's the code I use to generate my Atom feed:

protected void Page_Load(object sender, EventArgs e)
   // Code to retrieve DataTable of news articles
   StringBuilder feed = new StringBuilder();

   feed.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
   feed.Append("<feed xmlns=\"\">");
   feed.AppendFormat("<title>{0}</title>", titlegoeshere);
   feed.Append("<link href=\"\" />");
   feed.Append("<author><name>Eric Smith</name></author>");

   foreach (DataRow dr in dt.Rows)

   Response.ContentType = "text/xml";


The ASPX portion of this page should contain only the Page directive at the top of the file. My table contains an identity field called pkArticleID, which provides the unique link for each news entry. The AtomID field is a unique identifier, and the Title, Synopsis, and ReleaseDate fields are self-explanatory. At the feed level, I use the latest news article's release date as the updated value, as the data table I retrieve is sorted in reverse order by date—I just pull the first ReleaseDate field and put it in that field.

About the Author

Eric Smith is the owner of Northstar Computer Systems, a web-hosting company based in Indianapolis, Indiana. He is also a MCT and MCSD who has been developing with .NET since 2001. In addition, he has written or contributed to 12 books covering .NET, ASP, and Visual Basic. Send him your questions and feedback via e-mail at


  • wheloltabotly PumeSonee Phobereurce 6315153

    Posted by TizefaTaNaday on 06/03/2013 08:03am

    BroobrehagNer Viectteaw pusitonus

  • wholesale hats

    Posted by dvexpenueMoxjef on 03/29/2013 11:17pm

    [url=]cheap sunglasses[/url]cheap snapbacks from china [url=]cheap sunglasses[/url]cheap snapbacks free shipping [url=]cheap oakley[/url]cheap sunglasses [url=]cheap snapbacks free shipping[/url]cheap oakley [url=]wholesale snapbacks[/url]cheap sunglasses

  • snapback hats wholesale

    Posted by xtexpenueMoxjef on 03/29/2013 11:00pm

    [url=]snapback hats wholesale[/url]snapback hats wholesale [url=]cheap snapbacks[/url]oakleys cheap [url=]snapback hats wholesale[/url]cheap snapbacks for sale [url=]cheap sunglasses[/url]wholesale snapback hats [url=]snapback hats wholesale[/url]cheap snapbacks from china

  • wholesale designer sunglasses

    Posted by kgliliImpumpzia on 03/29/2013 10:52am

    sunglasses cheap [url=]sunglasses cheap[/url] fake ray ban wayfarer discount oakley sunglasses,,,,,o [url=]discount oakley sunglasses,,,,,o[/url] fake oakleys cheap fake oakley sunglasses [url=]cheap fake oakley sunglasses[/url] cheap ray ban sunglasses ray ban sunglasses cheap [url=]ray ban sunglasses cheap[/url] discount ray ban cheap sunglasses [url=]cheap sunglasses[/url] fake ray ban wayfarer wholesale sunglasses china [url=]wholesale sunglasses china[/url] cheap oakley frogskins cheap fake oakleys [url=]cheap fake oakleys[/url] oakley discount oakley discount [url=]oakley discount[/url] cheap wayfarer sunglasses

  • cop costume

    Posted by Fishnetdi1109 on 03/29/2013 09:28am - Office Tramp LingerieBoxer sets have grown to be extremely popular nowadays It can be quite sensual since it brings the body contours to proportion and this is why the sizing matters - Sexy Lingerie ShopInvite your co-workers, family and friends to join you Open an eBay storefront and increase your online auction sales - Sexy CostumesTherefore, you should choose a wholesale lingerie dress as per your body type and size and the style that suits your personality A pajama set might not sound too sexy, but if it is silky, and buttons up the front, it can make your woman feel very sexy, especially if she is a plus size (size 18 or larger) - black silk stockingsTip 9 – If you are going to be purchasing any lingerie on line it is best not to purchase through an auction site although the prices may be less In contrast of black, there is white which portrays a pure, clean and innocent image - Lace ChemiseA bra that is too tight can leave a pinching red mark on your back caused by the tightened elastic It gives a cute look to the area being covered while it accents the hips and reveals a small area of the butt

  • fake ray ban sunglasses

    Posted by dgliliImpumphef on 03/28/2013 10:09pm - cheap ray ban wayfarer fake oakleys - cheap sunglasses oakley sunglasses cheap - oakleys cheap discount ray ban sunglasses - ray ban wayfarer cheap wholesale sunglasses - designer sunglasses cheap cheap aviator sunglasses

  • cheap ray ban

    Posted by mgliliImpumpguq on 03/28/2013 10:07pm - discount ray ban ray ban sunglasses cheap - cheap sunglasses wholesale sunglasses - discount sunglasses oakley discount - cheap ray ban sunglasses wholesale sunglasses - wholesale oakley sunglasses oakleys for cheap

  • fake oakley sunglasses

    Posted by mgliliImpumppuf on 03/28/2013 08:28pm - fake oakley sunglasses cheap sun glasses - fake ray ban fake oakley sunglasses - fake ray ban wayfarer fake oakley sunglasses - fake ray ban oakley sunglasses cheap - fake ray ban akley discount

  • seszej

    Posted by Mandyeml on 03/28/2013 10:49am

    Snow smart, she began to discover to this mission is not simple, and clear the sixth sense told her crisis coming. Fat now? Him, but this time the most depressed person. Wanted to rely on his extraordinary strength, able to hand a little brother or two Xiaomi, mastermind of such an arrangement, too! It also makes him could not help but secretly sigh of unpredictable things. Well, the mastermind of the barrier disappears, ray ban wayfarer out. Blood wasteland east about 20 km away camp Rogge, since ray ban wayfarer sizes Select justice camp, where ray ban clubmaster must visit the. Well, oakley sunglasses out of it.oakley sunglasses discount, Xiao Feng noted that the mastermind of the unique barrier disappeared after that white light appeared. Psychological hold against the clock, Xiao Feng turned commanded said to the crowd.

  • ghd australia mnvnmn

    Posted by Suttonxct on 01/26/2013 08:42pm

    6bUlf ugg kOwt cTlh nike norge 5oIas toms shoes 8zVqh burberry sale 0fGbo bottes ugg 8zYiu longchamp pas cher 1kIug louis vuitton purses 6sGsi michael kors outlet 9xFdz christian louboutin 9pZpq cheap uggs 2tAnj nfl jerseys 2sTah 2vTpg ghd france 1kQka ugg sale

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date