https://github.com/mamantoha/xml_converter
Create hashes from XML documents easily.
https://github.com/mamantoha/xml_converter
crystal xml
Last synced: 10 months ago
JSON representation
Create hashes from XML documents easily.
- Host: GitHub
- URL: https://github.com/mamantoha/xml_converter
- Owner: mamantoha
- License: mit
- Created: 2018-11-25T19:08:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-26T10:04:58.000Z (almost 5 years ago)
- Last Synced: 2025-05-07T23:38:43.123Z (11 months ago)
- Topics: crystal, xml
- Language: Crystal
- Homepage:
- Size: 14.6 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XMLConverter
[](https://github.com/mamantoha/xml_converter/actions/workflows/crystal.yml)
Create hashes from XML documents easily.
`xml_converter` is heavily inspired by [ActiveSupport::XMLConverter](https://api.rubyonrails.org/classes/ActiveSupport/XMLConverter.html).
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
xml_converter:
github: mamantoha/xml_converter
```
2. Run `shards install`
## Usage
```crystal
require "xml_converter"
xml = <<-XML
Jehanne
Doe
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 ()
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
- [Anton Maminov](https://github.com/mamantoha) - creator and maintainer