XMLConverter
Create hashes from XML documents easily.
xml_converter
is heavily inspired by ActiveSupport::XMLConverter.
Installation
-
Add the dependency to your
shard.yml
:dependencies: xml_converter: github: mamantoha/xml_converter
-
Run
shards install
Usage
require "xml_converter"
xml = <<-XML
<person id="1">
<firstName preferredName="Jane">Jehanne</firstname>
<lastName>Doe</lastname>
</person>
XML
document = XML.parse(xml)
hash = XMLConverter.new(document).to_h
# => {"person" => {"id" => "1", "firstName" => {"preferredName" => "Jane", :value => "Jehanne"}, "lastName" => "Doe"}}
Contributing
- Fork it (https://github.com/mamantoha/xml_converter/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Anton Maminov - creator and maintainer