Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

Creating RSS Feeds

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Adding the XML Button

OK, so you've uploaded your RSS file onto your Web server. How do you let your eager public subscribe to your new feed? Answer: Display an RSS, XML, or Atom button on your Web page. You can download those buttons from the Internet (Figure 3.34). You can even capture RSS buttons from other RSS feeds; just make sure you have permission first.

Figure 3.34

Figure 3.34 You can download XML, RSS, or Atom buttons from the Internet.

How do you actually display an XML button and make it active in a Web page? First, put together the Web page in which you want to display your XML button, something like this:

<html>
  <head>
    <title>Subscribe to my feed</title>
  </head>

  <body>
    <h1>Subscribe to my feed</h1>
    Want to hear more of Steve's news? Subscribe to my feed!
    <br>

        .
        .
        .

  </body>
</html>

Then add the XML button. It's set up as a hyperlink to your XML file like this:

<html>
  <head>
    <title>Subscribe to my feed</title>
  </head>

  <body>
    <h1>Subscribe to my feed</h1>
    Want to hear more of Steve's news? Subscribe to my feed!
    <br>
    <a href="http://www.rssmaniac.com/steve/news.xml">
        .
        .
        .
    </a>
  </body>
</html>

Next, add the image for the RSS button. Assuming the name of the RSS button's image file is rss.jpg and it's in the same directory as the Web page where you want to display that button, the code might look like the following (the border="0" below removes the hyperlink border that would appear around the button—XML buttons don't usually show that border).

If your button's image is in another directory, make sure you add the right path to the image file's name—you can even use a URL that points to the image file on another server.

<html>
  <head>
    <title>Subscribe to my feed</title>
  </head>

  <body>
    <h1>Subscribe to my feed</h1>
    Want to hear more of Steve's news? Subscribe to my feed!
    <br>
    <a href="http://www.rssmaniac.com/steve/news.xml">
      <img src="rss.jpg" border="0">
    </a>
  </body>
</html>

This code gives you the Web page in which the XML button appears (see Figure 3.34). Very nice—now you've made your feed publicly available.

There's another way to add your RSS feed to a Web page. You can use the autodetect method, and browsers (like Firefox) or RSS readers that support this feature display an icon in the status bar (or use another technique) that allow users to automatically subscribe to your feed.

To set up autodetect, add a <link> element to a Web page's <head> section. For example, here's how you can set up autodetect to a news feed at http://rssmaniac.com/steve/news.xml using a <link> element:

<html>
  <head>
  <title>Subscribe to my feed</title>
  <link rel="alternate" type="application/rss+xml" title="RSS 2.0"
    href="http://rssmaniac.com/steve/news.xml" />
  </head>

  <body>
    <h1>Subscribe to my feed</h1>
    Want to hear more of Steve's news? Subscribe to my feed!
    <br>
    <a href="http://www.rssmaniac.com/steve/news.xml">
       <img src="rss.jpg" border="0">
    </a>
  </body>
</html>
  • + Share This
  • 🔖 Save To Your Account