Here is a small post on how to read an xml file using Hpricot in your Rails application.
First of all you need to install hpricot with the following command
gem install hpricot
Here is a sample xml file which I want to read. You can just paste the following code and create .xml file
<name> test </name>
<name> test 123</name>
Now here comes the code to read this file. Don’t forget to add require ‘hpricot’ in the controller where you are putting this code.
test = Hpricot::XML(File.open(“test.xml”, “r”))
(test/:profile).each do |pro| render :text=>(((pro.at(“name”).innerHTML.strip).to_s)+”=>”+(pro.at(“ _id”).innerHTML.strip).to_s).inspect and return false
Remove .inspect and return false once u get the required output
Hope this helps. If you have any doubts just post a message and I will try to reply.