# Two ways to generate RSS - rss/maker and rss/2.0 - which is better?

**URL:** <https://www.ruby-forum.com/t/two-ways-to-generate-rss-rss-maker-and-rss-2-0-which-is-better/171117>\
**Category:** Ruby\
**Created:** [June 26, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/two-ways-to-generate-rss-rss-maker-and-rss-2-0-which-is-better/171117 "2009-06-26T16:53:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [June 26, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/two-ways-to-generate-rss-rss-maker-and-rss-2-0-which-is-better/171117/1 "2009-06-26T16:53:41Z")

</div>

From some fiddling I’ve found that there are two ways to generate RSS  
using the rubyRSS libraries shipped with ruby 1.8.7.

Neither method seems ideal for generating RSS 2.0 (the RSS XML  
produced seems to be missing tags/attributes that I would like in both  
cases). Is there something that I’m missing and is there a preferred  
method?

In particular, I would like to use the ‘guid’ attribute with rss/maker  
but it seems to be unsupported? Surely there are some feed readers who  
depend on this for determining if an item is unique? It does seem the  
‘guid’ is a part of the RSS 2.0 standard.

However, if I were to use the rss/2.0 method, I could specify the  
guid, but would lose the dc:date attribute and all of the xmlns  
definitions at the top. Also with rss/2.0 I couldn’t work out how to  
do a reverse sort of items (is this even needed though).

Any comments?

Method 1: rss/maker, simplest example:

#!/usr/bin/env ruby  
require ‘rss/maker’

if **FILE** == $0  
content = RSS::Maker.make(‘2.0’) do |m|  
m.channel.title = “title”  
m.channel.about = “about” # \<\<\<=seems to not be used  
m.channel.link = “[www.example.com](http://www.example.com)”  
m.channel.description = “desc”  
m.items.do\_sort = true # \<\<\<= sort items by date

```
 2.times do |n|
   i = m.items.new_item
   i.title = "title"
   i.link = "www.example.com/" + n.to_s
   # i.guid = <<<=Not supported
   i.description = "Main body"
   i.date = Time.now
 end

```

end

puts content.to\_s  
end

Outputs:

\<?xml version="1.0" encoding="UTF-8"?\>

title  
[www.example.com](http://www.example.com)  
desc  
  
title  
[www.example.com/1](http://www.example.com/1)  
Main body  
Fri, 26 Jun 2009 16:35:31 +0200  
dc:date2009-06-26T16:35:31.598452+02:00\</dc:date\>  
  
  
title  
[www.example.com/0](http://www.example.com/0)  
Main body  
Fri, 26 Jun 2009 16:35:31 +0200  
dc:date2009-06-26T16:35:31.592903+02:00\</dc:date\>

Method 2: rss/2.0, simplest example:

#!/usr/bin/env ruby

require ‘rss/2.0’  
if **FILE** == $0

content = RSS::Rss.new(‘2.0’)  
channel = RSS::Rss::Channel.new

channel.title = “title”  
channel.link = “[www.example.com](http://www.example.com)”  
channel.description = “desc”  
#channel.item.do\_sort = true "\<\<\<=Cannot sort

2.times do |n|  
i = RSS::Rss::Channel::Item.new  
i.title = “title”  
i.link = “[www.example.com/](http://www.example.com/)” + n.to\_s  
i.guid = RSS::Rss::Channel::Item::Guid.new  
i.guid.content = n.to\_s  
i.guid.isPermaLink = true  
i.description = “Main body”  
i.date = Time.now  
channel.items \<\< i  
end

content.channel = channel  
puts content.to\_s

end

Outputs:

\<?xml version="1.0"?\> title www.example.com desc title www.example.com/0 Main body Fri, 26 Jun 2009 16:39:37 +0200 0 title www.example.com/1 Main body Fri, 26 Jun 2009 16:39:37 +0200 1 

Regards,  
Jonathan G…

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [June 27, 2009, 5:54am UTC](https://www.ruby-forum.com/t/two-ways-to-generate-rss-rss-maker-and-rss-2-0-which-is-better/171117/2 "2009-06-27T05:54:38Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Two ways to generate RSS - rss/maker and rss/2.0 - which is better?”  
on Fri, 26 Jun 2009 23:52:37 +0900,  
Jonathan G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> method?  
> Use RSS Maker. It generates RSS 2.0 object.

> In particular, I would like to use the ‘guid’ attribute with  
> rss/maker  
> but it seems to be unsupported? Surely there are some feed  
> readers who  
> depend on this for determining if an item is unique? It does  
> seem the  
> ‘guid’ is a part of the RSS 2.0 standard.

RSS Maker support ‘guid’ but it’s not ‘guid=’ method.

> ```
> # i.guid = <<<=Not supported
> 
> ```

i.guid.content = ‘xxx’  
i.guid.isPermaLink = true

generates

xxx

Thanks,
