views:

166

answers:

1

Hello, I'm trying to build an RSS feed using Grails and Rome.

In my controller's rss action, my last command is :

render(text: getFeed("rss_2.0"), contentType:"application/rss+xml", encoding:"ISO-8859-1 ")  

However, when I navigate to my feed's URL, the header is :

<?xml version="1.0" encoding="UTF-8"?>
    <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
    ...

My code for getFeed() is something like :

def getFeed(feedType) {
    def currentFeedURL = params.url

    def items = parserService.parse(new URL(currentFeedURL))

    def feedLink = "http://blablabla"

    def feedEntries = []


    items.each { item ->
        def entryTitle 
        if (item.price != null)
            entryTitle = item.description + " - " + item.price + " euros"
        else 
            entryTitle = item.description

        def itemContent = new SyndContentImpl(type:'text/plain', value: getBody(item))   

        SyndEntryImpl entry = new SyndEntryImpl(title: entryTitle,
                link: item.link,
                publishedDate: item.date,
                description: itemContent)
        feedEntries.add(entry)

    }

    def feed = new SyndFeedImpl(feedType: feedType,
        encoding : "ISO-8859-1",
        title: 'Some title',
        link: 'http://acme.com',
        description: 'Feed description',
        entries: feedEntries)


    StringWriter writer = new StringWriter()
    SyndFeedOutput output = new SyndFeedOutput()
    output.output(feed,writer)
    writer.close()
    return writer.toString()
}

And my getBody(item) is just parsing an item and outputting some HTML formatted text.

Does anyone have a clue about WHY the encoding is UTF-8 when I set it to ISO-8859-1 in the render method ???

Thanks for your help !

A: 

Could the 'getFeed("rss_2.0")' be pulling xml from another source? If so,could it be rendering that file's encoding instead of what render is specifying?

Vinny