xmlio
Mapping nim type to xml node, and parse from it.
Summary
| Latest Version | Unknown |
|---|---|
| License | LGPL-3.0 |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install xmlio
choosenim install xmlio
git clone https://github.com/codehz/xmlio
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| xmlio | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/codehz/xmlio |
|---|---|
| Homepage | https://github.com/codehz/xmlio |
| Registry Source | nimble_official |
README
XMLIO
Mapping nim type to xml node, use xaml-like semantics, <root name="123" /> equal to <root><root.name>123</root.name></root>.
Early development stage, break changes are expected!
Features
- Works with dynlib, can load new type from so/dll file, that's why I make this package (and vtable)
- Identify type by UUID, so it can be choosen manually to avoid conflict between dynlibs
- Use xmlns to avoid name conflict
Basic usage
DOCS: WIP (see tests for more examples)
- Import xmlio and xmlio/typeid_default
- Define your object type, only
string | SomeInteger | seq[T] | ref Tfield are supported (for now) - Register your type by using
generateXmlElementHandler, you need provide a UUID for it, and put verify code in body - Define the xmlns and xmlns registry instance
- Call
readXmlto parse xml - Done!
import xmlio, xmlio/typeid_default
type MyRoot = object of RootObj
name: string
secret: int32
generateXmlElementHandler MyRoot, "015a1611-9a98-4cb7-b77f-c7dc56b44507":
if self.name == "": raise newException(ValueError, "name should not be empty!")
if self.secret != 123: raise newException(ValueError, "secret is not matched")
var registry = newSimpleRegistry()
var rootns = newSimpleXmlnsHandler()
rootns.registerType("root", ref MyRoot)
registry["std"] = rootns
var root = readXml(registry, """<root xmlns="std" name="name"><root.secret>123</root.secret></root>""", ref MyRoot)
echo root.name # name
echo root.secret # 123