Sha256: 4d6134c8d2824725df6e117c90c5add0922e5dde621ab303e43078aa7ac80ee7
Contents?: true
Size: 588 Bytes
Versions: 32
Compression:
Stored size: 588 Bytes
Contents
module RTurk class AnswerParser require 'cgi' def self.parse(xml) answer_xml = Nokogiri::XML(CGI.unescapeHTML(xml.to_s)) answer_hash = {} answers = answer_xml.xpath('//xmlns:Answer') answers.each do |answer| key, value = nil, nil answer.children.each do |child| next if child.blank? if child.name == 'QuestionIdentifier' key = child.inner_text else value = child.inner_text end end answer_hash[key] = value end answer_hash end end end
Version data entries
32 entries across 32 versions & 1 rubygems