how do I open an uploaded xml in controller?

Hello,

This seems like a fairly simple solution, but I keep running into roadblocks. I'm using a small form to select an xml from the user's local file system, and then parsing the information out using REXML. The form works fine, but I can't seem to get the body of the xml doc opened with in the controller. I've included the code snippets below for view and controller, can anyone see what i'm missing/doing wrong?

thanks, Dave

view:   <% form_tag (:action => 'uploadXML', :multipart => true) do %>     <%= file_field_tag 'file' %></p>     <%= submit_tag "Upload" %>   <% end %>

controller:   require 'rexml/document'   include REXML

  def uploadXML     xml_file = params[:file].read     elements = Document.new File.new(xml_file)

    elements.root.each_element do |e|       .......     end   end

I am not sure if you can directly read params[:file] as a file handle. I could be wrong.

if you debug your output by typing logger.info(#{xml_file}) might provide some hints.

Hello,

This seems like a fairly simple solution, but I keep running into roadblocks. I'm using a small form to select an xml from the user's local file system, and then parsing the information out using REXML. The form works fine, but I can't seem to get the body of the xml doc opened with in the controller. I've included the code snippets below for view and controller, can anyone see what i'm missing/doing wrong?

thanks, Dave

view: <% form_tag (:action => 'uploadXML', :multipart => true) do %>    <%= file_field_tag 'file' %></p>    <%= submit_tag "Upload" %> <% end %>

controller: require 'rexml/document' include REXML

def uploadXML    xml_file = params[:file].read    elements = Document.new File.new(xml_file)

Just elements = Document.new params[:file] should do the trick, or elements = Document.new xml_file would
probably work too.

Fred