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.
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 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) 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.
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.
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:
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.
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:
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.
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. |