REXML - XML query only returning one (last) result

I’m really new to Ruby on Rails, and I’m trying to read an XML file
with REXML. No matter what I try, I am only getting the last result
returned from my query. I should be getting 365 results. Here is the
code:

include REXML
require ‘rexml/document’
require ‘rexml/xpath’

class MakeFootprintController < ApplicationController
def index
file = File.new("#{RAILS_ROOT}/xml/footprints.xml")
doc = Document.new(file)
doc.each_element(’//day’) { |day|
render_text day
}
end
end

Thanks for the help.

On 29 Sep 2007, at 19:10, Giant Jam Sandwich wrote:

I’m really new to Ruby on Rails, and I’m trying to read an XML file
with REXML. No matter what I try, I am only getting the last result
returned from my query. I should be getting 365 results. Here is the
code:

By default, render_text sets the response body (instead of appending
to it), so all your calls to render_text are overwriting each other,
render_text takes extra parameters that allow you to override this
Calling render_text more than once isn’t really right though. (You
could use a partial or something).

Fred

Thanks Fred!

On Sep 29, 2:56 pm, Frederick C. [email protected]