## You should edit getrss.rb class RSSHTML # Start at a document tree node and continue down the tree, # formatting elements as we come across them. def recurseXML (root,formatProc) string = '' root.elements.each("item") {|el| string += formatProc.call(el)} root.each do |el| if(el.type == REXML::Element) string += recurseXML(el,formatProc); end end return string end def initialize(title,url) @title=title @conn=nil @data=nil @xml=nil @html=nil @rawdata=nil ## Right now we only handle URLs in strings, but in the ## future, I'd like to add file parsing and other things... if ((url.type == String) && ## Split the host, port, and path from the URL (url =~ /http:\/\/([^\/:]+)(:([0-9]+))?(.*)/)) then @host=$1 @port=($3==nil) ? 80 : $3.to_i @file=($4=="") ? '/' : $4 end end # Get the RSS feed as formatted HTML. Be sure to pass in a code # block which takes a single argument: the REXML Element to be # formatted. def getHTML return recurseXML(getXML.root,Proc.new) end # Get a REXML::Document from this XML feed. def getXML @xml = REXML::Document.new getRaw if(@xml == nil) return @xml end # Get the raw XML text def getRaw if(@rawdata == nil) then begin @conn = Net::HTTP.new(@host,@port) @conn.start resp, @rawdata = @conn.get(@file,nil) rescue TimeoutError return '' end end return @rawdata end def getTitle return @title end end