Creating RSS feeds using Freemarker

As a follow up to the earlier post on using freemarker, here is an example of creating RSS 2.0 feeds using a freemarker template. This FTL will work assuming there is an input javabean that has a collection accessible via getItems() and returns a list of Item objects. Each Item would have a title, description, link, and last modified date properties as shown below:

<rss version="2.0">
<channel>
<#list items as myitem>
<item>
 <title>${myitem.title?html}</title>
 <description>${myitem.description?html}</description>
 <link>${myitem.link}</link>
 <pubDate>${myitem.lastmodifiedDate?datetime}</pubDate>
 </item>
</#list>
</channel>
</rss>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: