Generating Atom Feed from SQL Data
- Anatomy of an Atom Feed
- Generating the Entry Elements
- Generating the Feed Header
- Adding the Glue
Atom technology (not the one discussed by nuclear physicists) was created in 2003 to address the shortcomings of the then-prevalent RDF Site Summary (RSS; also known as Really Simple Syndication) family of incompatible formats. It gained widespread adoption when Google decided to use it as the Application Program Interface (API) to a variety of its services including Blogger, Gmail, Google News, Google Blog Search, and Google Maps. The Atom format is becoming a generic protocol facilitating data exchange between web services and applications. For example, the Google Maps support the display of locations encoded within an Atom feed with the GeoRSS elements.
In this article, you'll see how you can create an Atom feed from data in your SQL database. We'll use a simple product description table containing product identifiers, names, and descriptions:
CREATE TABLE Products ( PartNo nvarchar(20) NOT NULL, ProductName nvarchar(200) NOT NULL, ProductDescription nvarchar(max) NOT NULL, CONSTRAINT PK_Products PRIMARY KEY CLUSTERED (PartNo ASC) )
You could place this feed directly onto your web site to allow your visitors to subscribe to new product information.