Skip to content

edjCase/motoko_xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage

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); // <root attr1="value1"><br/></root>

let xmlObj : Element.Element = Xml.deserialize("<root attr1=\"value1\"><br/></root>".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

About

XML encoding/decoding library in motoko

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages