AppsScriptPulse

Make an RSS Feed with Google Apps Script – Digital Inspiration

RSS flickr photo by Lars Plougmann shared under a Creative Commons (BY-SA) license

ThinkAmI uses the XMLService of Google Apps Script to create a valid RSS feed that is served to the browser using ContentService with the MIME type set as RSS.

Recently I was looking for a Google Apps Script snippet to create a RSS data feed. Back in the day Apps Script used to have a Xml.parseJS() method which could make a data feed from a JavaScript array. It was announced that the old XML service would be replaced by XmlService in 2013 so we are not talking breaking news here.

The RSS helper script created by ThinkAml and shared by Amit Agarwal makes it a lot easier to generate a feed in a couple of lines of code. To let you see I’ve included a snippet and click through to the source post for the full code:

    var rss = makeRss();
rss.setTitle('RSS 2.0 Feed with Google Apps Script');
rss.setLink('http://example.com');
rss.setDescription('RSS 2.0 Feed');
rss.setLanguage('en');
rss.setAtomlink('http://example.com/rss');
for (var i = 1; i < 3; i++) {
rss.addItem({
title: 'TITLE:' + i,
link: 'http://example.com/#' + i,
description: 'DESCRIPTION: ' + i,
pubDate: new Date()
})
}

Source: Make an RSS Feed with Google Apps Script – Digital Inspiration

Leave a Reply

Your email address will not be published.

Subscribe to AppsScriptPulse...