Imports System Imports System.Data Imports System.Data.OleDB Imports System.Configuration Imports System.Web Imports System.Xml Namespace googleBaseFeed Public Class createXMLFeed : Inherits System.Web.UI.Page Sub Page_Load(sender as Object, e as EventArgs) '### CLEAR THE BROWSER OUTPUT AND WRITE TEXT/XML HEADER Response.Clear() Response.ContentType = "text/xml" Response.ContentEncoding = Encoding.UTF8 Dim objX As New XmlTextWriter(Response.OutputStream, Encoding.UTF8) objX.WriteStartDocument() objX.WriteStartElement("rss") objX.WriteAttributeString("version", "2.0") objX.WriteAttributeString("xmlns:g", "http://base.google.com/ns/1.0") objX.WriteStartElement("channel") objX.WriteElementString("title", "Your website title") objX.WriteElementString("description", "Your website description") objX.WriteElementString("link", "http://www.yourwebsite.com/") '### GET ALL PRODUCTS; DATABASE CONNECTION SPECIFIED IN WEB.CONFIG FILE Dim myConnection as New oleDBConnection(ConfigurationManager.AppSettings("yourDNS")) Dim myCommand as New oleDBCommand("SELECT productId, productTitle, productDesc, productPrice, productLink, productImage, productBrand, productType, productUPC, productWeight FROM myProducts ORDER BY productId", myConnection) Dim myReader As OleDbDataReader Try myConnection.Open() myReader = myCommand.ExecuteReader() While myReader.Read() '### OPEN AND WRITE THE ITEM ELEMENT objX.WriteStartElement("item") objX.WriteElementString("id", myReader("productId").toString()) objX.WriteElementString("title", myReader("productTitle").toString()) objX.WriteElementString("description", Server.HtmlEncode(myReader("productDesc").toString())) objX.WriteElementString("g:price", myReader("productPrice").toString()) objX.WriteElementString("link", myReader("productLink").toString()) objX.WriteElementString("g:image_link", myReader("productImage").toString()) objX.WriteElementString("g:brand", myReader("productBrand").toString()) objX.WriteElementString("g:product_type", myReader("productType").toString()) objX.WriteElementString("g:upc", myReader("productUPC").toString()) objX.WriteElementString("g:weight", myReader("productWeight").toString()) '### CLOSE ITEM objX.WriteEndElement() End While myReader.Close() Finally myConnection.Close() End Try myConnection.Dispose() '### CLOSE CHANNEL objX.WriteEndElement() '### CLOSE RSS objX.WriteEndElement() objX.WriteEndDocument() objX.Flush() objX.Close() Response.End() End Sub End Class End Namespace