lib/echonest/response.rb in youpy-ruby-echonest-0.0.2 vs lib/echonest/response.rb in youpy-ruby-echonest-0.0.3

- old
+ new

@@ -1,13 +1,13 @@ -require "rexml/document" +require "xml" module Echonest class Response attr_reader :xml def initialize(body) - @xml = REXML::Document.new(body) + @xml = XML::Document.string(body) end def status @status ||= Status.new(@xml) end @@ -30,20 +30,20 @@ INVALID_PARAMETER = 5 attr_reader :code, :message def initialize(xml) - @code = xml.elements['response/status/code'][0].to_s.to_i - @message = xml.elements['response/status/message'][0].to_s + @code = xml.find('/response/status/code').first.content.to_s.to_i + @message = xml.find('/response/status/message').first.content.to_s end end class Query def initialize(xml) @parameters = {} - xml.elements.each('response/query/parameter') do |parameter| - @parameters[parameter.attributes['name'].to_sym] = parameter.text + xml.find('/response/query/parameter').each do |parameter| + @parameters[parameter['name'].to_sym] = parameter.content end end def [](parameter_name) @parameters[parameter_name]