sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

Hash.from_xml

Returns a Hash containing a collection of pairs when the key is the node name and the value is
its content

  xml = <<-XML
    <?xml version="1.0" encoding="UTF-8"?>
      <hash>
        <foo type="integer">1</foo>
        <bar type="integer">2</bar>
      </hash>
  XML

  hash = Hash.from_xml(xml)
  # => {"hash"=>{"foo"=>1, "bar"=>2}}

+DisallowedType+ is raised if the XML contains attributes with <tt>type="yaml"</tt> or
<tt>type="symbol"</tt>. Use <tt>Hash.from_trusted_xml</tt> to parse this XML.

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/hash/conversions.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Hash-from_xml-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/hash/conversions.rbgit commit -m "better docs for Hash.from_xml"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Hash-from_xml-for-pr

hub pull-request


# Celebrate!