How do I convert a Ruby hash to XML?

前端 未结 5 801
傲寒
傲寒 2020-12-05 23:04

Here is the specific XML I ultimately need:



  joe@example.com
           


        
5条回答
  •  孤街浪徒
    2020-12-05 23:12

    Gem gyoku very nice.

    Gyoku.xml(:lower_camel_case => "key")    
    # => "key"
    
    Gyoku.xml({ :camel_case => "key" }, { :key_converter => :camelcase })
    # => "key"
    
    Gyoku.xml({ acronym_abc: "value" }, key_converter: lambda { |key| key.camelize(:lower) })
    # => "value"
    

    and more useful options.

提交回复
热议问题