Giant Jam Sandwich
2007-Sep-29 18:10 UTC
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Sep-29 19:56 UTC
Re: REXML - XML query only returning one (last) result
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Giant Jam Sandwich
2007-Oct-02 13:35 UTC
Re: REXML - XML query only returning one (last) result
Thanks Fred! On Sep 29, 2:56 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---