ASPRSS - Enabling you to share your ASP resources
ASPRSS --> Becoming a publisher: Creating your RSS file

If you haven't yet read the overview, you should do so now.

This page describes in detail the steps you need to follow before you can publish your data with RSS.

What exactly is in the RSS file?

XML data. eXtensible Markup Language is a very simple format, especially if you're fluent in HTML.

In fact, if you're not an experienced web developer fluent in HTML and Active Server Pages we should point out that you will need to do some server-side programming to automatically create your RSS file. If instead you intend to manually create your file, read our guide for non-developers.

Here's an example of XML from an RSS file. Note that every start tag <tag> has an end tag </tag>, and that the tags can contain other tag pairs. We'll help you create your own RSS file containing information about pages on your site later.

<channel rdf:about="http://MySuperSite.com/">
   <title>James' super site</title>
   <link>http://MySuperSite.com/</link>
   <description>It's a super site about super things</description>
   <dc:creator>James Shaw (mailto:[email protected])</dc:creator>
   <image rdf:resource="http://MySuperSite.com/SuperImage.gif" />
</channel>

Where do I put the RSS file?

We recommend placing your RSS file in the root folder of your web site.

It is important to note that this does not have to be the root folder of your host domain. You can still register http://www.abc.com/mysite/ as an RSS publisher. There may be another RSS-publishing web site at http://www.abc.com/theirsite/ too - that's ok.

How do I create the RSS file?

We provide all the code you'll need to create your RSS file. You only have to modify it to connect to your database or wherever you store links to your articles.

All of the source code is contained in this zip file. Download that now, extract the files and copy them onto your web site.

The source code comprises just two files: MakeRSS_xx and RSSpub_xx, although the zip file contains versions for all of the supported languages and platforms. The xx will depend on the language of your choice:

• vbs.asp - Active Server Pages written in VBScript
• js.asp - Active Server Pages written in JavaScript
• vb.aspx - Active Server Pages.NET written in VB     (Thanks to T.Zinni at ITproLogic User Group for this contribution)

The languages below are not currently supported, but will be soon. Can you help?

• cs.aspx - Active Server Pages.NET written in C# (c-sharp)
• js.aspx - Active Server Pages.NET written in JScript.NET

What changes do I need to make?

Obviously, depending on which language you choose the sample code will be different, so we won't step you through line-by-line. However, every version has certain things in common which we document here.

Firstly, every version consists of two files - only one of which, MakeRSS, you have to modify to suit your site. The other file, RSSpub, contains the code that does the hard work for you. The intention is that any updates that we make to this file will only require you to copy the new file to your server.

The first thing that MakeRSS must do is get the data about the resources you're going to publish. The sample code gives an example of connecting to a database and executing an SQL query, but you can use whatever means necessary.

// open database
oConn.Open ( sConnectionString )

// get recordset
oRS.Open 'SELECT * FROM Articles', oConn

Having got your data (and we'll assume it's in a recordset for this explanation) the next thing to do is call a standard function, RSSheader. This function creates the start of the XML document.

// now start to create the XML

If Not RSSheader ( sSiteTitle, sSiteDescr, sSiteURL, sSiteDetails, sImageURL, sFurtherReading, sAuthorNames, sAuthorEmails ) Then
   Response.End  // quit
End If

Note that all the RSSxxx functions return true/false. Please test the return value of every function call you make, and take appropriate action if the function fails and false is returned. Your RSS file is NOT modified until the RSSpersist function is called at the end of this process.

Since this is the first function that has taken parameters you need to know how they work. First, some of the parameters to this function are optional - you don't have to supply values for them. If you don't have a value, pass an empty string - probably signified by "" or '' depending on language. Your sample code will have an example.

Let's walk through the parameters passed into RSSheader:

ParameterMandatoryDescription
sSiteTitleYesThe name of your website.
sSiteDescrYesA description of your website
sSiteURLYesThe URL of your website with a trailing / character, e.g. "http://www.abc.com/". Do not include the name of a page (e.g. default.htm) in this URL.
sSiteDetailsNoFurther details such as address, telephone, fax - less likely to be used by Directories.
sImageURLNoThe URL of a 100x30 gif image, e.g. "http://www.abc.com/images/mylogo.gif". Some directories may show this image next to your resources.
sFurtherReadingNoThe URL of another RSS file that should be included. Directories may follow these links when processing your RSS.
sAuthorNamesNoThis can contain more than one value, separated by a | character. As an example, to pass in the names of two authors, Jack and Jill, you would pass the following string: "Jack|Jill".
sAuthorEmailsNoJust as for sAuthorNames, this can contain more than one email address. Both must contain the same number of items.

Note that the author parameters can be specified globally or for each article, as we'll see in a moment. Just remember that any article that doesn't specify any author(s) will default to those specified here.

Next, loop through your resources, calling RSSitem for each one.

If Not RSSitem ( sTitle, sDescr, sURL, sDate, sCategory, sKeywords, sAuthorNames, sAuthorEmails ) Then
   Response.End
End If

ParameterMandatoryDescription
sTitleYesThe title of the resource
sDescrYesA description of your resource.
sURLYesThe URL of your resource, e.g. "http://www.abc.com/MyFirstArticle.asp".
sDateNoThe date the resource was last modified. RSSitem will cope with most common date formats.
sCategoryNoUsed as a hint to the Directories, this should be one of the following options: "Articles", "News", "Products", "Services", "Websites"
sKeywordsNoA list of suggested keywords that the Directories can optionally use in their search engine. Seperate keywords with commas.
sAuthorNames
sAuthorEmails
NoAs described above in RSSheader, any authors here will be used for this resource only.

Continue to call RSSresource for each resource you have.

After all the resources are output, all that remains to finish the XML is to call RSSfooter:

If Not RSSfooter Then
   Response.End
End If

After RSSfooter is called you have completed creating your XML, but it hasn't been stored into your RSS file. (It may be that you don't want to, and instead have written a page that "outputs" the XML to the client - simply output the contents of the sRSSXML variable in this case.)

Normally you will write the XML to your RSS file. To do that, call RSSpersist, passing in the name of the file to create or overwrite. Remember that you'll need to enable write permission to this file.

If Not RSSpersist ( "/RSS.xml" ) Then
   Response.End
End If

You're done! Congratulations on creating your RSS file. You should validate it, then become a member (it's free) so you can appear on the Publishers page.

Also, consider upgrading your membership and get your resources submitted to all the directories automatically!


Contact us  -  Tell your colleagues  -  Show your support  -  Your privacy

Copyright © 2003 James Shaw. All rights reserved.
Online communities!   Check out Dozing Dogs ASP.NET CMS