Skip to content

Instantly share code, notes, and snippets.

@melito
Created April 11, 2009 00:26
Show Gist options
  • Save melito/93377 to your computer and use it in GitHub Desktop.
Save melito/93377 to your computer and use it in GitHub Desktop.
def deserialize_xml(response)
doc = Hpricot.XML(response)
(doc/'items/').each do |elemen|
name = elemen.name.gsub(/\-/, '_')
if elemen.children.size > 1
stak = []
elemen.children.each {|x| stak.push(x.inner_html) if x.elem? }
self.instance_variable_set("@#{name}", stak)
else
self.instance_variable_set("@#{name}", elemen.inner_html)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment