https://github.com/belloq/xml_mapper
A simple XML mapper for Elixir.
https://github.com/belloq/xml_mapper
elixir xml
Last synced: 4 months ago
JSON representation
A simple XML mapper for Elixir.
- Host: GitHub
- URL: https://github.com/belloq/xml_mapper
- Owner: belloq
- License: mit
- Created: 2017-02-12T11:44:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-18T11:16:46.000Z (about 8 years ago)
- Last Synced: 2025-10-21T18:44:39.632Z (8 months ago)
- Topics: elixir, xml
- Language: Elixir
- Size: 12.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XMLMapper
A simple XML mapper for Elixir.
## Installation
```elixir
def deps do
[{:xml_mapper, "~> 1.0.0"}]
end
```
## Example
```elixir
defmodule Category do
use XMLMapper
element :id, :integer, tag: "ID"
has_many :products, Product
end
defmodule Product do
use XMLMapper
tag "ProductItem"
element :id, :integer, tag: "ID"
element :name, :text
end
Category.to_xml(%{id: 1, products: [%{id: 1, name: "Product1"}, %{id: 2, name: "Product2"}]})
#=> "11Product12Product2"
Product.to_struct("2Product2")
#=> %{id: 2, name: "Product2"}
```
## TODO
- [ ] default values
- [ ] value parser callback
- [x] escape html characters
- [ ] cdata
- [ ] prefixes
- [ ] override tag name of sub-items in has_many
- [ ] rename no_escape flag to escape
- [ ] add escape flag to modules & global settings