xml_converter v0.4.0

Create hashes from XML documents easily.

XMLConverter

CI

Create hashes from XML documents easily.

xml_converter is heavily inspired by ActiveSupport::XMLConverter.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      xml_converter:
        github: mamantoha/xml_converter
    
  2. 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

  1. Fork it (https://github.com/mamantoha/xml_converter/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

xml_converter

Owner
Statistic
  • 8
  • 0
  • 0
  • 2
  • 0
  • over 3 years ago
  • November 25, 2018
License

MIT License

Links
Synced at

Thu, 07 Nov 2024 12:53:52 GMT

Languages