I am trying to use Google Apps Script to output a formatted RSS feed of upcoming events from a calendar that I can then insert into a Mailchimp Template.
This is the HTML I am using to generate the rss feed:
<rss version="2.0">
<channel>
<title><?= "Title" ?></title>
<? var cal = CalendarApp.getCalendarById('CalendarID');
var today = new Date();
var future = today.addDays(90); //Uses separate function to add days to look ahead
var events = cal.getEvents(today, future);
for (var t in events) { ?>
<item>
<? var start = new Date(events[t].getStartTime())
var date = Utilities.formatDate(start, 'GMT', 'dd/MM/yyyy')
var title = events[t].getTitle()
var time = start.toTimeString().substring(0, 5) ?>
<title><?= date+' - '+time ?></title>
<description><?= title ?></description>
</item>
<? } ?>
</channel>
</rss>
This is the doGet() script the URL calls:
function doGet() {
return ContentService.createTextOutput(HtmlService.createTemplateFromFile("rss").evaluate().getContent())
.setMimeType(ContentService.MimeType.RSS);
}
But whenever I pass it through feedburner or any other RSS Reader it comes up with the same response:
The URL does not appear to reference a valid XML file. We encountered the following problem: Error on line 921: The element type "meta" must be terminated by the matching end-tag ""
Even though the call loads fine in a normal browser window as a RSS feed.
I have also the tired the GAS RSS example using the XKCD feed (found here) and I am getting same response.
Any thoughts on what I am doing wrong I have set the web app permissions to Execute as me and Anyone, even anonymous. As said the in the example. Have tried other combinations with no luck as well.
Thanks