Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/edjcase/motoko_xml

XML encoding/decoding library in motoko
https://github.com/edjcase/motoko_xml

Last synced: about 1 month ago
JSON representation

XML encoding/decoding library in motoko

Awesome Lists containing this project

README

        

# Funding

This library was originally incentivized by ICDevs. You can view more about the bounty on the forum or website. The bounty was funded by The ICDevs.org commuity and the award paid to @Gekctek. If you use this library and gain value from it, please consider a donation to ICDevs.

# Overview

This is a library that handles XML serialization and deserialization with UTF8 bytes and text

# Package installation

## MOPS

### CLI

Run `mops install xml`

### Or manually:

Modify the `mops.toml` file to add:

```
[dependencies]
xml = "{version}"
```

where `{version}` is the version number you want to use

See detailed MOPS documentation [here](https://mops.one/docs/install)

# Usage

```motoko
import Element "mo:xml/Element"
import Xml "mo:xml/Xml"
...

let element : Element.Element = {
name = "root";
attributes = [{ name = "attr1"; value=?"value1" }];
children = #open([
{
name = "br";
attributes = [];
children = #selfClosing;
}
])
}
let serializedXml : Text = Xml.serialize(element); //

let xmlObj : Element.Element = Xml.deserialize("
".chars())
```

# First time setup

To build the library, the `MOPS` library must be installed. It is used to pull down packages and running tests.

MOPS install instructions: https://mops.one/docs/install

# Testing

To run tests, use the `make test` command or run manually with `mops test`.
The tests use MOPS test framework