I am completely new to Ruby and Rails... in fact I created my first application in Rails today that makes an HTTP request to pull back an XML document and then outputs it to the screen.. something simple to get started..
Well I am needing to now parse the XML string but am lost on how to do that exactly with Hpricot.
Here is my code so far
Controller
require 'hpricot'
class HelloController < ApplicationController
def index
h = Hello.new
@tickets = Hpricot(h.ticket_list)
end
end
Model
def ticket_list
url = URI.parse("http://example.com/test.xml")
req = Net::HTTP::Get.new(url.path)
req.basic_auth @@uname, @@pwd
res = Net::HTTP.new(url.host, url.port).start do |http|
http.request(req)
end
return res.body
end
How would I pass information into my view?