Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Overbryd/exoml
A module to decode/encode xml into a tree structure
https://github.com/Overbryd/exoml
Last synced: 2 months ago
JSON representation
A module to decode/encode xml into a tree structure
- Host: GitHub
- URL: https://github.com/Overbryd/exoml
- Owner: Overbryd
- License: mit
- Created: 2017-08-22T00:12:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-02T16:10:42.000Z (almost 5 years ago)
- Last Synced: 2024-10-18T12:59:05.072Z (3 months ago)
- Language: HTML
- Size: 190 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - HTML - A module to decode/encode xml into a tree structure. (XML)
- fucking-awesome-elixir - exoml - A module to decode/encode xml into a tree structure. (XML)
- awesome-elixir - exoml - A module to decode/encode xml into a tree structure. (XML)
README
# Exoml
A module to decode/encode xml into a tree structure.
```
{:exoml, "~> 0.0.4"},
```## Examples
Handles well formed xml/html.
```elixir
Exoml.decode("some text")
{:root, [],
[{"tag", [{"foo", "bar"}],
["some text", {"self", [{"closing", "closing"}], nil}]}]}
```Handles bare strings.
```elixir
Exoml.decode("what, this is not xml")
{:root, [], ["what, this is not xml"]}Exoml.decode("")
{:root, [], []}
```Handles stuff that any browser would render.
```elixir
Exoml.decode("Well, it renders in the browser")
{:root, [], ["Well, it renders ", {"b", [], ["in the browser"]}]}
```One can easily `decode/1` and `encode/1` without loosing too much of the original document.
```elixir
xml = ~s'some text'
^xml = Exoml.encode(Exoml.decode(xml))
# => "some text"
```## Performance
See `bench/` directory or run `mix bench` upon checkout.
There is one performance test that uses a `131K` html file.On a `MacBookPro11,5 i7 2.5GHz 16GB RAM` it yields:
```
benchma iterations average time
encode 100 12716.29 µs/op
decode 50 42088.74 µs/op
```## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `exoml` to your list of dependencies in `mix.exs`:```elixir
{:exoml, "~> 0.0.2"}
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/exoml](https://hexdocs.pm/exoml).