xmlpackage

Tag: xmlpackage

New Products RSS Feed for ASPDotNetStoreFront

I?ve just recently completed work on a New Product RSS feed for one of my ASPDNSF customers and thought I?d post it here for all to benefit from. This package uses the already existing RssFeed.aspx files that come with ASPDNSF for display. To use the attached XMLPackage, you?ll need to do the following:

Here are some of the more interesting things about the XMLPackage that might going through the code a good learning experience. The first is identifying the odd format that RSS feeds expect dates to be in. Below is the SQL code to format the date string (in this case for the item creation date (to be used as the published date)

  <query name="Items" rowElementName="Item">
    <sql>
      <![CDATA[
                select top @Limit ProductID, ProductGUID, Name, SEName, Description, 
                LEFT(DATENAME(dw, CreatedOn), 3) 
                + ',' + ' ' + RIGHT('0'+CAST(DATEPART(DAY, CreatedOn) AS CHAR(2)),2) + ' ' + LEFT(DATENAME(m, CreatedOn),3)
                +  ' ' + CAST(YEAR(CreatedOn) AS CHAR(4)) 
                + ' ' + CONVERT(varchar,CreatedOn,108) + ' PST' AS CreatedDate
                from dbo.product with (nolock) 
                where Deleted = 0 and Published=1
                order by createdon desc
            ]]>
    </sql>
    <querystringreplace replaceTag="@Limit" replacetype="request" replaceparamname="limit" defvalue="5" validationpattern="^\d{1,10}$" />
  </query>

This formats the dates into a string that looks like the following: 

Wed, 8 Oct 2008 15:40:02 PST

as opposed to a standard SQL date that look like this:

2008-11-28 14:34:05.920

I just found it much easier to manipulate this in SQL than in XSL.

One key to properly providing an RSS feed for consumption is to provide the last build date so that RSS readers aren?t needlessly downloading articles. This is provided by determining the most recently created item and stuffing it into the LastCreatedDate. The RSS Channel includes Generator, Title, Link, Description, Copyright, Date, lastBuildDate, and image elements; all except the image elements are drawn from AppConfig or System values to minimize the need to modify this file unless you need to. This XMLPackage also includes the following elements of the RSS Item specification: title, link, description, author, guid, date, pubDate and image. In the case of Item, all the values are drawn from the product database including properly formatting the product link URL and the item image URL.

I?m looking forward to hearing how people are going to use this application. Please use the feedback section below to let me know what you think of this XMLPackage!

New Product RSS Feed v1.0 download