API and XML Data rails 3 Nokogiri

mis-fleeman

New Member
This is my first attempt at getting data back from an api and getting the data to output to a view at least for now in my app.I want to be able to put an ISBN number into a search form and get the data back for that particular book.(using http://isbndb.com/). Someone has already kindly pointed me in the right direction but now I am stuck and was hoping for some pointers. This is what I have so farController\[code\]require 'open-uri'class BookController < ApplicationController def searchbook resp = open("http://isbndb.com/api/books.xml?access_key=#{'API KEY HERE'}&results=details&index1=isbn&value1=#{params[:isbn]}") doc = Nokogiri.XML(resp.read) # ... process response here endend\[/code\]Form\[code\] <%= form_tag({:controller => 'book', :action => 'searchbook'}, {:method => 'get'}) do |select| %> <%= label_tag :isbn, "Enter ISBN Number" %> <%= text_field_tag :isbn, params[:isbn] %> <%= submit_tag "Search" %> <% end %>\[/code\]So my first question is how do i process an XML request or what can i read to find out how?Second question is where can i view the data being returned in the console (if any), I'm not even sure that this is doing anything as yet, however upon clicking search in my form I am taken the the searchbook action which is a blank page for now..Pointers appreciated, not necessarily the answer as I want to understand what's going on, though if someone did provide an answer I could learn off that also as I can take things in easier when looking at examplesI appreciate I may be a long way off from the whole answer but this is my first time doing thisThank you
 
Back
Top