<%@ Page Language="C#" AutoEventWireup="true"%><%@ Import Namespace="System.Xml"%><%@ Import Namespace="System.Linq"%><%@ Import Namespace="System.Xml.Linq"%><script runat="server"> protected void Page_Load(object sender, EventArgs e) { // load your product collection here ProductCollection pc = ProductCollection.Load(false); XNamespace g = "http://base.google.com/ns/1.0"; XDocument doc = new XDocument( new XDeclaration("1.0", null, null), //new XComment("Sample RSS Feed"), new XElement("rss", new XAttribute("version", "2.0"), new XAttribute(XNamespace.Xmlns + "g", g), //"http://base.google.com/ns/1.0" new XElement("channel", new XElement("title", "eStore Products for XYZ"), new XElement("link", "http://" + Request.Url.Host), new XElement("description", "Products available at our store."), from product in pc orderby product.Name ascending select new XElement("item", new XElement("title", product.Name), new XElement("link", "http://" + Request.Url.Host + RouteHelper.Parse("/product.aspx?ProductID=" + product.ID)), new XElement("description", product.Description), new XElement(g + "image_link", "http://" + Request.Url.Host + product.DefaultImage + CustomImage.Get80x80), new XElement(g + "price", product.Price) ) ) ) ); // save Xml output to website/app root folder doc.Save(Server.MapPath("~/") + "products.xml", SaveOptions.None); // debug to html // Response.Write(new XDeclaration("1.0", null, null).ToString() + "\r\n" + doc.ToString()); } </script>
Remember Me
Page rendered at Sunday, August 01, 2010 9:31:19 AM (South Africa Standard Time, UTC+02:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.