class Hash

def to_xml(options = {})

options like :dasherize and friends, they are forwarded to the builder.
configure your own builder with the :builder option. The method also accepts
The default XML builder is a fresh instance of Builder::XmlMarkup. You can

By default the root node is "hash", but that's configurable via the :root option.

}
"Time" => "dateTime"
"DateTime" => "dateTime",
"Date" => "date",
"FalseClass" => "boolean",
"TrueClass" => "boolean",
"Float" => "float",
"BigDecimal" => "decimal",
"Integer" => "integer",
"Symbol" => "symbol",
XML_TYPE_NAMES = {

added as well according to the following mapping:
Unless the option :skip_types exists and is true, an attribute "type" is
+value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added.
* Otherwise, a node with +key+ as tag is created with a string representation of

#
# fooing!
#
# =>
{ foo: Foo.new }.to_xml(skip_instruct: true)

end
end
options[:builder].bar 'fooing!'
def to_xml(options)
class Foo

* If +value+ responds to +to_xml+ the method is invoked with +key+ as :root.

# => "foo"
{foo: lambda { |options, key| options[:builder].b(key) }}.to_xml

callable can add nodes by using options[:builder].
with +key+ as :root, and +key+ singularized as second argument. The
on the arity, the callable is invoked with the +options+ hash as first argument
* If +value+ is a callable object it must expect one or two arguments. Depending

and +key+ singularized as :children.
* If +value+ is an array there's a recursive call with +key+ as :root,

* If +value+ is a hash there's a recursive call with +key+ as :root.

the _values_. Given a pair +key+, +value+:
To do so, the method loops over the pairs and builds nodes that depend on

#

# 2
# 1
#
#
# =>
{ foo: 1, bar: 2 }.to_xml

Returns a string containing an XML representation of its receiver:
def to_xml(options = {})
  require "active_support/builder" unless defined?(Builder::XmlMarkup)
  options = options.dup
  options[:indent]  ||= 2
  options[:root]    ||= "hash"
  options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])
  builder = options[:builder]
  builder.instruct! unless options.delete(:skip_instruct)
  root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)
  builder.tag!(root) do
    each { |key, value| ActiveSupport::XmlMini.to_tag(key, value, options) }
    yield builder if block_given?
  end
end