How do I convert XML into a hash in Rails?

后端 未结 5 1815
北海茫月
北海茫月 2021-01-05 08:28

How do I convert an XML body to a hash in Ruby?

I have an XML body which I\'d like to parse into a hash


    
           


        
5条回答
  •  轮回少年
    2021-01-05 09:04

    The original question was asked some time ago, but I found a simpler solution than using Nokogiri and searching for specific names in the XML.

    Nori.parse(your_xml) will parse the XML into a hash and the keys will have the same names as your XML items.

提交回复
热议问题