Write a xml file to the public folder possible?

Hello,

im generating xml data without problems when working as a web
service(accesing from the action), but i cant figure it out how to
instead of showing that xml data in the browser it gets writed on a xml
in the public folder, i really havent find a way to do this and im
getting a little nervous, thi is what i have:

http://www.rorpaste.com/paste/details/812

Any help in how to get that data on the public folder will be very
appreciated. :slight_smile:

Evan T. wrote:

Hello,

im generating xml data without problems when working as a web
service(accesing from the action), but i cant figure it out how to
instead of showing that xml data in the browser it gets writed on a xml
in the public folder, i really havent find a way to do this and im
getting a little nervous, thi is what i have:

http://www.rorpaste.com/paste/details/812

Any help in how to get that data on the public folder will be very
appreciated. :slight_smile:

you need to save this to a file - so instead of using a template, create
the xml as output (REXML; ruby xml), and save it into a file with the
File class.

http://www.germane-software.com/software/rexml/docs/tutorial.html is an
excellent link. (documentation
http://www.germane-software.com/software/rexml/doc/index.html )

after you create the xml, use the File class to create the file

File.open(RAILS_ROOT+‘public/somefile.xml’, ‘w’) do |file|
file << The_Xml_Output
end

hth

Hi,

you need to save this to a file - so instead of using a template, create
the xml as output (REXML; ruby xml), and save it into a file with the
File class.

you still have another option here if you want to use a builder (rxml)
template. In your controller you can use render_to_string for calling
the action associated to the rxml and get the output as a string. Then
you can do exactly as Shai told you for saving it to a file :slight_smile:

regards,

javier ramirez

This works great if the rexml/document is smaller than 32768 bytes
(32k). I have generated a rexml output larger than 32k and when I
write the output to the file it will just record the first 32768 bytes
off of the output xml. Any thoughts on how to make this work for any
output size?

If I throw the output to the client browser everything is in there, so
I know the output is just fine…

Thanks!

Ricardo

On Aug 22 2007, 7:17 am, Shai R. <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs