Knowledge Base

How can I use HTML to format my RSS feed?

The example RSS template in the RSS documentation has been built to fully comply with the RSS 2.0 specifications.  Unfortunately those specifications do not cover a good method for using HTML in your feed.  As a result, your feed may appear as a large block of text in your aggregator.  Without a clearly defined standard to deal with HTML many different methods have emerged.  Unfortunately, because these alternate methods are not part of the RSS specification, they may not be handled the same by all aggregators.  One possible option that seems to work well in most aggregators is to wrap elements containing HTML in a CDATA section.

Here is an example of the line in the default RSS template that might contain weblog field entries with HTML.

<description>{exp:xml_encode}{summary}{body}{/exp:xml_encode}</description>

To modify this example, the {exp:xml_encode} tag should be replaced with the CDATA section as shown in the following example.

<description><![CDATA[{summary}{body}]]></description>

Your feeds should now show the HTML formatting.  Remember that not all aggregators work the same.  The feed might show up fine in one aggregator but not another.

Last Updated on Feb 27, 2007 at 09:44   ( Permalink )
Category: Templates, RSS, Atom, and Feeds