# RSS feed help

**URL:** <https://www.ruby-forum.com/t/rss-feed-help/132504>\
**Category:** Rails\
**Created:** [March 20, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/rss-feed-help/132504 "2008-03-20T21:05:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 20, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/1 "2008-03-20T21:05:20Z")

</div>

I have created a xml file that I want to change into and rss feed and  
then parse it so it looks anyother rss feed. The file takes data from my  
database but I am at a loss on how to get this to an rss feed, can  
anyone help?

view

xml.instruct! :xml, :version=\>“1.0”  
xml.product\_record do  
@products.each do |p|  
xml.itemtype(p.item\_type)  
xml.itemname(p.item\_name)  
xml.description(p.description)  
xml.sellername(p.seller\_name)  
xml.selleremail(p.seller\_email)  
end  
end

controller

class InfoController \< ApplicationController  
def prodlist  
@products = Product.find(:all, :order=\> “item\_name”)  
render :layout =\> false  
end  
end

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 20, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/2 "2008-03-20T23:21:27Z")

</div>

Hey Alan. Here’s how I create RSS in Rails:

view

xml.instruct!

xml.rss “version” =\> “2.0”, “xmlns:dc” =\> “[http://purl.org/dc/elements/](http://purl.org/dc/elements/)  
1.1/” do  
xml.channel do  
@products.each do |p|  
xml.title(p.item\_name)  
xml.link(url\_for :only\_path =\> false, :controller =\> ‘products’)  
xml.description(p.description)  
end  
end  
end

That’d get you the basics. Is that all you need?

ESPNDev

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 21, 2008, 10:56am UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/3 "2008-03-21T10:56:59Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hey Alan. Here’s how I create RSS in Rails:
> 
> view
> 
> xml.instruct!
> 
> xml.rss “version” =\> “2.0”, “xmlns:dc” =\> “[http://purl.org/dc/elements/](http://purl.org/dc/elements/)  
> 1.1/” do  
> xml.channel do  
> @products.each do |p|  
> xml.title(p.item\_name)  
> xml.link(url\_for :only\_path =\> false, :controller =\> ‘products’)  
> xml.description(p.description)  
> end  
> end  
> end
> 
> That’d get you the basics. Is that all you need?
> 
> ESPNDev

That works really well, not sure why it only shows one item will have to  
figure taht out but definatly a great starting point thanks.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 21, 2008, 11:38am UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/4 "2008-03-21T11:38:35Z")

</div>

Ok I tried ro find out whats wrong by validating the rss feed and it  
complains that there are too many titles and such. I believe this could  
be the problem as to why is not showing all the products but im at quite  
a loss can anyone help?

source code

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

Fiat  
[http://localhost:3000/products](http://localhost:3000/products)  
In good condition, 5 years old.  
KLSexxy  
removed\_email\_address@domain.invalid

```
<title>Great Hits</title>
<link>http://localhost:3000/products</link>
<description>Greatist rock hits ever!!</description>
<sellername>JAY01</sellername>
<selleremail>removed_email_address@domain.invalid</selleremail>
<title>Trek</title>

<link>http://localhost:3000/products</link>
<description>Proffesional Trek riding bike, want to sell for no less 

```

than £50. The bike can be delivered or can be collected. Please  
contact via email.  
JG02  
removed\_email\_address@domain.invalid

Whats appears on site

Trek

* * *

Proffesional Trek riding bike, want to sell for no less than Â£50. The  
bike can be delivered or can be collected. Please contact via email.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 21, 2008, 5:03pm UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/5 "2008-03-21T17:03:51Z")

</div>

I believe you are missing tags. You need to wrap each  
product as an item grouping. For examples of a working RSS feed I  
suggest you pull your favorite source and have a look inside.

– Long  
[http://FATdrive.tv/wall/trakb/10-Long](http://FATdrive.tv/wall/trakb/10-Long)  
[http://FATdrive.tv/](http://FATdrive.tv/) - store, play, share

----- Original Message -----  
From: “Alan Red” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, March 21, 2008 5:38 AM  
Subject: [Rails] Re: RSS feed help

Ok I tried ro find out whats wrong by validating the rss feed and it  
complains that there are too many titles and such. I believe this  
could  
be the problem as to why is not showing all the products but im at  
quite  
a loss can anyone help?

source code

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

Fiat  
[http://localhost:3000/products](http://localhost:3000/products)  
In good condition, 5 years old.  
KLSexxy  
removed\_email\_address@domain.invalid

```
<title>Great Hits</title>
<link>http://localhost:3000/products</link>
<description>Greatist rock hits ever!!</description>
<sellername>JAY01</sellername>
<selleremail>removed_email_address@domain.invalid</selleremail>
<title>Trek</title>

<link>http://localhost:3000/products</link>
<description>Proffesional Trek riding bike, want to sell for no

```

less  
than £50. The bike can be delivered or can be collected. Please  
contact via email.  
JG02  
removed\_email\_address@domain.invalid

Whats appears on site

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 21, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/rss-feed-help/132504/6 "2008-03-21T17:45:37Z")

</div>

Long wrote:

> I believe you are missing tags. You need to wrap each  
> product as an item grouping. For examples of a working RSS feed I  
> suggest you pull your favorite source and have a look inside.
> 
> – Long  
> [http://FATdrive.tv/wall/trakb/10-Long](http://FATdrive.tv/wall/trakb/10-Long)  
> [http://FATdrive.tv/](http://FATdrive.tv/) - store, play, share
> 
> ----- Original Message -----  
> From: “Alan Red” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Sent: Friday, March 21, 2008 5:38 AM  
> Subject: [Rails] Re: RSS feed help

Long thanks so much, got it fully working. It looks fantastic  
considering its only for a uni project but every bit counts thanks again
