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’ %>
<%= 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