An open API service indexing awesome lists of open source software.

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.

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