Topic: XML to Hash
I've parsed an XML-document using Hpricot and would like to convert it to JSON. Form what I understand I have to convert it to a hash first, then convert it to JSON.
Does anyone have any idea how to convert XML to a hash?
Thanks!
You are not logged in. Please login or register.
I've parsed an XML-document using Hpricot and would like to convert it to JSON. Form what I understand I have to convert it to a hash first, then convert it to JSON.
Does anyone have any idea how to convert XML to a hash?
Thanks!
Hash.from_xml should do the trick. I read about it here: http://archives.ryandaigle.com/articles h-from-xml
Also, someone else has used Hpricot to do the 'same' thing here: http://refactormycode.com/codes/932-cre ng-hpricot
Go through this URL which describes how to convert an XML body to a hash in Ruby and you may solve your problem: http://stackoverflow.com/questions/4150 h-in-rails
Hosting provided by aTech Media