def get_xml_element(url,xml_element)
require 'net/http'
response=Net::HTTP.get_response(URI('http://api.platform.com/cinema/halls/format/xml/cid/1/pid/10000'))
#~ puts response.code
s = response.body
#~ puts s
s.scan(/\<#{xml_element}\>(.*)\<\/#{xml_element}\>/)
end
url='http://api.platform.com/cinema/halls/format/xml/cid/1/pid/10000'
puts get_xml_element(url,'errorMessage')
解析json
require 'net\http'
require 'json'
response=Net::HTTP.get_response(URI('http://api.platform.com/cinema/halls/format/json/cid/1/pid/10000'))
puts response.body
data=response.body
result=JSON.parse(data)
p result
puts result['res']['errorMessage']