Extending an RSS Feed With Namespaced Elements

Use commonly defined and supported namespace-based modularization to extend your feed.

Overall, I’d recommend building a simple feed to start, especially since it’s hand coded. As you get more comfortable with it you can start to test out new features.

Beginning in RSS 1.0 namespace-based modularization was developed. This allows developers to create additional modules to enhance and extend the basic capabilities of RSS. Your syndicated feed can be extended through the use of these namespaces.

Declare a namespace in the <rss> root element of your RSS file. When we used the atom:link element in Building an RSS Feed: Compatibility, which required the Atom namespace, we were doing just that.

As mentioned in Understanding XML for RSS: XML Namespaces, the URL pointer exists to give the namespace a unique identity in your document. The URL will sometimes point to documentation for the module, but it’s not required, and in some cases the original pages no longer exist, though the namespace lives on.

Common Namespaces

Different feed readers will support different namespaces, but these are the most common that you will use in an RSS 2.0 feed.

Atom

http://www.w3.org/2005/Atom

<atom:link>

xmlns:content="http://purl.org/rss/1.0/modules/content/"
<atom:link href="https://www.htmlhobbyist.com/feed.xml" rel="self" type="application/rss+xml" />

There are five potential values that can be used in the rel attribute:

self
Is a URL pointing to the location of the feed and is useful for feed compatibility. If you don’t include any other atom:links, at least include this one.
enclosure
Similar to the enclosure element, it’s used to describe an audio or video media object.
via
Similar to the source element, it provides a link back to original source of the item, if different than the publisher of the feed.
alternate
Links to an alternate representation (such as a web page or text document) of the feed content.
related
Links to a related resource.

Content

http://purl.org/rss/1.0/modules/content/

xmlns:content="http://purl.org/rss/1.0/modules/content/"

The W3C Validation Service doesn’t validate any elements in this space other than content:encoded.

<content:encoded>

<content:encoded

For main content. If you think of the description as being an excerpt or summary of an item, the the content:encoded can be the main content itself. It’s often filled with HTML code.

Syndication

http://purl.org/rss/1.0/modules/syndication/

xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"

The Syndication elements serve a similar purpose as the elements discussed in Enhancing an RSS Feed Channel: Feed Reader Caching Instructions. They tell the feed reader how often the feed is expected to have fresh content.

<sy:updateBase>

<sy:updateBase>1970-01-01T00:00Z</sy:updateBase>

The date and time when the updatePeriod and updateFrequency calculations should begin, represented in W3CDTF format.

<sy:updateFrequency>

<sy:updateFrequency>1</sy:updateFrequency>

The number of times in the updatePeriod that the feed should refresh. An updatePeriod of hourly and a frequency of 6 would have the feed refreshed every 10 minutes.

<sy:updatePeriod>

<sy:updatePeriod>weekly</sy:updatePeriod>

Accepted values are hourly, daily, weekly, monthly, or yearly.

Dublin Core

http://purl.org/dc/elements/1.1/

xmlns:dc="http://purl.org/dc/elements/1.1/"

Dublin Core is a comprehensive list of metadata elements that you can use to describe the information in your syndicated feed. Go to Section 3: Properties in the /elements/1.1/ namespace for documentation.

<dc:creator>N.E. Lilly<dc:creator>

The dc:creator is often used in place of author, managingEditor and webMaster elements, when credit should be given, but you don’t want to expose an email address, as required by those elements.

There are a wide variety of other elements, most of these aren’t as useful for our purposes, but if you’re publishing academic content or journalism elements like publisher, format, and contributors might be useful to you. Check out the Using Dublin Core guide, especially the section and additional links about RDF/XML and using The Elements, if you feel the needs to get very descriptive and/or pedantic with your website content.