[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rss feed item error

baur79

11/3/2007 9:29:00 AM

Hi everybody,
i'm new in ruby
here is i get an error.

source code

require 'rss/2.0'
require 'open-uri'
url = 'http://www.nationalbank.kz/rss/rate...
feed = RSS::Parser.parse(open(url).read, false)
puts "=== Channel: #{feed.channel.title} ==="
feed.items.each do |item|
puts item.title
puts " (#{item.pubDate})"
puts
puts item.description
puts item.index
end

partial rss feed (you can see all feed following the url = 'http://
www.nationalbank.kz/rss/rates.xml')

<item>
<title>EUR</title>
<pubDate>05.11.07</pubDate>
<description>175.11</description>
<index>DOWN</index>
<link/>
</item>

error message:
auto_rss.rb:12: undefined method `index' for #<RSS::Rss::Channel::Item:
0x2d3758c> (NoMethodError)
from auto_rss.rb:7:in `each'
from auto_rss.rb:7


the code goes good if i not out put "puts item.index",
but as you see i can't change the feed
and i need the value of <index> item.

is there any way to get the value of <index> item

please help me,
best regards from Kazakhstan / Shymkent city

2 Answers

Kouhei Sutou

11/3/2007 12:45:00 PM

0

Hi,

In <1194082144.258243.176010@k79g2000hse.googlegroups.com>
"Rss feed <index> item error" on Sat, 3 Nov 2007 18:30:17 +0900,
baur79 <baur79@gmail.com> wrote:

> but as you see i can't change the feed
> and i need the value of <index> item.

What is <index>? Who does define <index>?

> is there any way to get the value of <index> item

require 'rss'
require 'open-uri'

module RSS
class Rss::Channel::Item
install_have_child_element("index", "", "?")
end
BaseListener.install_get_text_element("", "index", "index")
end

url = 'http://www.nationalbank.kz/rss/rate...
feed = RSS::Parser.parse(open(url).read, false)
feed.items.each do |item|
puts item.index
end


Thanks,
--
kou

baur79

11/3/2007 7:42:00 PM

0

thanks a lot, for your big help!