Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Creating an RSS Feed for Your FrontPage Web Site

Office 2003
 

Lisa Wollin
Microsoft Corporation

August 2005

Applies to:
    Microsoft Office FrontPage 2003

Summary:   Learn about RSS and how to programmatically create an RSS file for your FrontPage 2003 Web site. The download that accompanies this article contains a VBA project and an XSLT file that you can use to generate and display RSS feeds. (9 printed pages)

Download RSSTool.exe.


Contents

Introduction to Creating an RSS Feed
Programmatically Generating an RSS File
Conclusion
Additional Resources

Introduction to Creating an RSS Feed

If you spend any time on the Internet, you have probably heard of RSS, and you may decide that you need an RSS feed for your Web site. An RSS feed is an Extensible Markup Language (XML) file that people can use to keep up to date with the content on a Web site. RSS feeds are frequently associated with weblogs (blogs), but you can use them for any Web site.

Note   Similar to HTML, XML is a markup language designed for the Internet. However, unlike HTML, which was designed to define formatting of Web pages, XML was designed to describe data. You can use XML to develop custom schemas. As with HTML, the World Wide Web Consortium defined the specifications for XML. For more information on XML and the XML specification, see Extensible Markup Language (XML).

Generally, sites that frequently publish content, such as news sites, offer RSS feeds, which enable customers to keep up with new content published. When you provide an RSS feed for your customers, they can use news readers or aggregators to subscribe to the feed. Then, every time you publish new content and update your RSS file, news readers automatically notify customers who have subscribed to the feed.

If you have a Web site that contains content that you frequently update, such as articles or stories, you may want an RSS feed to help your customers keep up with your updates. This article explains the XML behind RSS and provides a Microsoft Office FrontPage 2003 Visual Basic for Applications (VBA) project that you can use to programmatically generate an RSS feed for your FrontPage Web site. The download for this article includes an Extensible Stylesheet Language Transformation (XSLT) file that you can use to display the RSS XML file in a browser.

Note   XSLT is a language designed to transform XML documents into other documents. For more information on XSL and XSLT, see Extensible Stylesheet Language (XSL) and XSL Transformations (XSLT).

What Is RSS?

RSS is an abbreviation of Really Simple Syndication, although a few sites refer to it as Rich Site Summary or RDF Site Summary. RSS is basically an XML document that conforms to a specific XML schema. Seven RSS schema formats are available; each is slightly different. To simplify your work, this article uses the latest version, version 2.0.

Many resources available on the Internet explain RSS and the various RSS schemas. Here are a few resources that you might find useful:

Creating an RSS File

Various organizations created several different versions of RSS schemas. This article explains the most recent RSS schema, version 2.0. To help you understand how the schema works and how to create your own RSS feed, the following code shows the basic XML for RSS 2.0.

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
   <channel>
      <title></title>
      <link></link>
      <description></description>
      <item>
         <title></title>
         <link></link>
         <dc:creator></dc:creator>
         <pubDate></pubDate>
         <description></description>
      </item>
   </channel>
</rss>

The preceding code shows a simplified version of the XML for the RSS 2.0 schema. For a complete list of the elements and an element reference, see the excellent RSS 2.0 Specification reference on the Weblogs at Harvard Law Web site.

Briefly, each RSS feed that adheres to the RSS 2.0 schema contains one channel element. Some of the child elements for the channel element are optional, but title, link, and description are required. The channel element may contain one or more item elements. Many of the child elements for the item element are optional, but title, link, and description are required. The preceding code provides the required elements for both the channel and item elements plus two optional elements, the dc:creator and pubDate elements, that may be useful.

If you think of an RSS feed as a newspaper, the channel element contains the name of the newspaper, a link to the newspaper's Web site, and a description of the newspaper. Each item element contained within the channel element represents a different article in the newspaper by containing the title of the article, a link to where the article can be found online, a description of the article, and the name of the author.

You can manually create and edit an RSS file in FrontPage, Microsoft Visual Studio, Microsoft Notepad, or another XML or text editor. In addition, several RSS tools can generate the RSS XML for you. This article includes a VBA tool that you can use to generate an RSS XML file from within your FrontPage Web site. You can adapt the code in the tool to fit your specific needs.

Most RSS files place the most recent content at the top of the file. This allows subscribers to easily find the new content. However, you can use an XSLT to sort the item elements by date, which is what the RSS example that the VBA project included with this article does.

Publishing an RSS File

After you create your RSS file, you need to upload it to your Web site. Then you need to create a link to it from your Web site so that people can subscribe to it. Most sites that offer RSS feeds use a graphic similar to Figure 1, which is the image used on MSDN.

Example of an RSS graphic

Figure 1. Example of an RSS graphic

You can use a variety of different graphics with your RSS file. For more possible graphics, see RSS Graphics on the RSS Specifications Web site.

After you provide the link to the RSS file on your Web site, all you need to do is update the file when you publish new content—daily, weekly, monthly, or whatever works for you. However, you should always use the same file name instead of using a different name every time you update the RSS XML. If you use a different name, those who have subscribed to your RSS feed can't keep their news aggregators updated without obtaining the URL to the new file. Simply update the file and reuse the same file name.

This section provides what you need to know about creating your own RSS feed. The remainder of this article explains how to use the VBA tool included in the download and how to set up your Web site to use the tool to generate the RSS file; it also describes both the VBA code behind the tool and the XSLT that accompanies the RSS XML file.

Programmatically Generating an RSS File

There are many possible solutions for programmatically generating an RSS feed. You could create an ASP solution that generates the RSS file on the server, or you could create a tool that generates the RSS feed using the file system on your local machine. This article includes a tool that you can use to generate an RSS feed for your FrontPage Web site. This section explains how to install and use the tool and the accompanying files. It also explains how to set up the pages in your site to use the tool and the XML that the tool creates.

To use the RSS tool, download and install the files included with this article. The download package includes the files listed in Table 1.

Table 1. Contents of the RSS Tool download

File Name Description
frmRssProps.frm VBA form
frmRssProps.frx Supporting file for the VBA form
rss.xsl XSLT file for the RSS XML file
Note   This tool works in FrontPage 2003 only and is not designed to work in previous versions of FrontPage.

Installing the RSS Tool

After you install the files on your local machine, you can import the VBA form into a VBA project.

To import the VBA form into a VBA project

  1. Start FrontPage.
  2. Start the Visual Basic Editor. (To do this, on the Tools menu, point to Macro and then click Visual Basic Editor; or press ALT+F11.)
  3. On the File menu in the Visual Basic Editor, click Import File.
  4. Navigate to where you installed the downloaded files and select the file named frmRssProps.frm.
  5. Click Open.

After you complete these steps, the form is listed in Project Explorer. If you have never added any other files or modules to your Visual Basic macro project, your Project Explorer appears similar to the one shown in Figure 2.

Visual Basic Editor Project Explorer

Figure 2. Visual Basic Editor Project Explorer

Setting Up the RSS Tool

To make the RSS tool easy to use, the following instructions provide a simple macro to display the form and explain how to add a button to a toolbar that runs the macro.

To add a macro to display the RSS tool form

  1. In the Visual Basic Editor, open the Module1 module by double-clicking it in Project Explorer.
  2. At the end of the code in Module1, paste the following code.
    Public Sub ShowRssForm()
       Dim frm As frmRssProps
    
       Set frm = New frmRssProps
       frm.Show
       Set frm = Nothing
    End Sub
    
    
  3. Save the module and close the Visual Basic Editor.

To add a button to a toolbar

  1. In FrontPage, right-click any toolbar and click Customize. Alternatively, you can click Customize on the Tools menu.
  2. On the Commands tab of the Customize dialog box, select Macros from the Categories list.
  3. From the Commands list, click and drag Custom Button onto any toolbar.
  4. Right-click on the button that you just added, and click Assign Macro.
  5. In the list of macros, select ShowRssForm.
  6. Click OK, and then click Close.

Setting Up Your Web Pages

The VBA RSS tool uses metadata to insert page descriptions, so for descriptions to appear in the RSS feed, you need to add a META element to each page. The following code shows an example of the META element to add.

<meta name="description" 
content="Learn about the best wines and wineries of the Tuscany region of Italy.">

You should note that the META data is required only if you want the VBA RSS tool to include page descriptions in the RSS feed. If your page does not contain META data for page descriptions, the VBA RSS tool still runs and generates an RSS feed as expected. In addition, add the description META data to only the pages that you want to appear in your RSS feed because the VBA RSS tool checks the date of each page to determine whether to add it to the RSS XML file.

Using the RSS Tool

Now that you have set up the tool and prepared your Web pages, you can generate your RSS XML file.

To create an RSS feed

  1. Click the toolbar button that you added earlier.
    Note   If nothing happens when you click the toolbar button, go back to the earlier sections and ensure that you assigned the ShowRssForm macro to the button.
  2. Set the options as needed. The options are explained in the section RSS Tool Options.
  3. Click Create RSS File.

RSS Tool Form

The form for the RSS tool is shown in Figure 3.

VBA form for RSS tool

Figure 3. VBA form for RSS tool

RSS Tool Options

Table 2 explains each of the form options.

Table 2. Create RSS Feed form options

Option Name Description
Create feed for all files in the Web site Default. When you select this option, the RSS tool creates an RSS feed that includes all the files in the Web site with .htm, .html, .asp, or .aspx extensions. All other files are omitted from the feed, which means that image files and supporting files, such as JavaScript code files and cascading style sheets, are not included in the feed.
Create feed only for files in the folder specified below When the form loads, it creates a list of all folders, except hidden folders, that are in your Web site. When you select this option, you must specify the folder that contains the files that you want included in your RSS feed.
Number of days since page was last updated This option allows you to limit the RSS feed to include only files that have been updated within a specified number of days. The default is seven days, or one week; however, you can specify more days. Specifying a value of -1 forces the RSS feed to include all files regardless of when a file was last updated.
Name of the Web site or title of the RSS feed Specifies the name of the Web site. If blank, the tool uses a default value.
URL or address of the Web site Specifies the URL of the Web site. If blank, the tool uses a default value.
Description for the RSS feed Specifies the introductory text for the RSS feed. If blank, the tool uses a default.

Understanding the Code

The RSS tool included in the download uses the FrontPage VBA object model to generate the RSS XML and create the RSS file. Most of the code behind the form is basic. There are three instances where the code may need a bit of additional explanation. The following sections explain these instances.

Listing the Folders

When FrontPage first displays the form, the form code loops through the folders in the active Web site and adds the names to the list box, as shown in the following code.

For Each objFolder In objSite.AllFolders
   intLocation = InStr(1, Mid(objFolder.Name, 1, 1), "_")
   If Not objFolder.IsRoot And intLocation = 0 Then
      lstFolders.AddItem objFolder.Name
   End If
Next

As shown in the preceding code, if the folder is either the root folder or is one of the hidden folders that FrontPage requires, the names of which start with an underscore (_), the code does not add the folder to the list box.

Adding the Appropriate Files to the Feed

When the code concatenates the XML string, it loops through the files in the entire Web site or the selected folder, and then determines whether to add the file to the feed. The following example contains the code to add the files to the feed.

For Each objFile In objFiles
   If objFile.Extension = "htm" Or objFile.Extension = "html" Or _
         objFile.Extension = "asp" Or objFile.Extension = "aspx" Then
      strPubDate = objFile.Properties("vti_timelastmodified")
      intPubDate = strPubDate

      If txtDate = -1 Or intPubDate >= intDate Then
         strTitle = objFile.Title
         strUrl = Replace(objFile.Url, objWeb.Url & "/", "")
         strDescription = objFile.MetaTags("Description")

         strXml = strXml & vbTab & vbTab & "<item>" & vbCrLf
         strXml = strXml & vbTab & vbTab & vbTab & "<title>" & _
            strTitle & "</title>" & vbCrLf
         strXml = strXml & vbTab & vbTab & vbTab & "<link>" & _
            strUrl & "</link>" & vbCrLf
         strXml = strXml & vbTab & vbTab & vbTab & "<dc:creator>" & _
            objFile.Properties("vti_author") & "</dc:creator>" & vbCrLf
         strXml = strXml & vbTab & vbTab & vbTab & "<pubDate>" & _
            strPubDate & "</pubDate>" & vbCrLf
         strXml = strXml & vbTab & vbTab & vbTab & "<description>" & _
            strDescription & "</description>" & vbCrLf
         strXml = strXml & vbTab & vbTab & "</item>" & vbCrLf
      End If
   End If
Next

In the preceding code, two conditions must be met before the code adds a file to the feed. First, the file must have an extension of .htm, .html, .asp, or .aspx. Second, the difference between the current date and the date the page was last updated must be equal to or less than the value of the Number of days since page was last updated option. However, if the Number of days since page was last updated option contains a value of -1 the code adds the file to the feed regardless of the updated date.

Programmatically Creating and Saving an XML File

Finally, the RSS tool creates an XML file. However, because FrontPage cannot programmatically paste an XML string into a file, the code creates the file as an HTML page and then uses the DocumentHTML property to paste the generated XML string. Then the code uses the Move method to rename the file with an .htm extension. The following code shows how this is done.

Private Sub CreateXMLPage(Xml As String)
   Dim objFile As WebFile

   Set objFile = ActiveWeb.AllFiles.Add("rss.htm", True)
   objFile.Open

   ActiveDocument.DocumentHTML = Xml
   ActivePageWindow.Save True
   ActivePageWindow.Close

   objFile.Move "rss.xml", False, True
End Sub

You can view the code discussed in these sections and the remainder of the code for the RSS tool in the VBA form file included in the download. After you have imported the file into your VBA project, you can access the form and all the code behind the form from within the Visual Basic Editor.

Conclusion

Including an RSS feed is almost standard for Web sites, and RSS feeds will be increasingly common in the future. You can generate the RSS file manually using FrontPage or another XML or text editor, or you can create the RSS file programmatically using an ASP page or another tool. The RSS tool included in this article is just one of many possible ways to programmatically create an RSS feed for your FrontPage Web site.

Additional Resources

Many online resources provide more detailed information about RSS and explain how to create your own feed. These are just a few possible resources.

You can find many more development resources for FrontPage and Microsoft Office at the following locations:

Show:
© 2015 Microsoft