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

https://github.com/wojtekmach/easyxml

An experimental easy-to-use XML library for Elixir.
https://github.com/wojtekmach/easyxml

Last synced: 6 months ago
JSON representation

An experimental easy-to-use XML library for Elixir.

Awesome Lists containing this project

README

          

# EasyXML

[Docs](http://wojtekmach.pl/docs/easyxml)

An experimental easy-to-use XML library for Elixir.

## Features

* Convenient access via the `doc[xpath]` notation

* Pretty printing via the `Inspect` protocol

* Supports multiple backends:

* `EasyXML.Backend.Xmerl` (default)
* `EasyXML.Backend.Saxmerl`

## Usage

The easiest way to use EasyXML is with `Mix.install/2` (requires Elixir v1.12+):

```elixir
Mix.install([
{:easyxml, "~> 0.1.0-dev", github: "wojtekmach/easyxml", branch: "main"}
])

doc =
EasyXML.parse!("""




""")

EasyXML.xpath(doc, "//point[1]")
#=> [#EasyXML.Doc[]]

EasyXML.xpath(doc, "//point/@x")
#=> ["1", "3"]

EasyXML.xpath(doc, "//point") |> Enum.map(& &1["@x"])
#=> ["1", "3"]

doc["//point[1]/@x"]
#=> "1"
```

## License

Copyright (c) 2021 Wojtek Mach

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.