magus v0.3.0 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
1 min read

xml

Build, serialize, and parse XML/SVG.

Naming convention: import the module under its bare name (import "xml"), reach members with a backslash, and call methods in camelCase: xml\someMethod.

Methods

render

Serialize an XML node to a string. A node is a string (text) or an element map {"tag": name, "attrs": [name, value, ...], "children": [node, ...]}. Empty-children elements self-close; no whitespace is emitted between tags.

Signature: xml\render(node) → string · source

Parameter Type Optional Description
node any

Returns: string

element

Build an element node from a tag, a flat [name, value, ...] attribute list, and a list of child nodes (elements or strings). Sugar for the {"tag", "attrs", "children"} map that render consumes.

Signature: xml\element(tag, attrs, children) → any · source

Parameter Type Optional Description
tag string
attrs []string
children any

Returns: any

parse

Parse an XML string into a node tree: each element becomes {"tag": name, "attrs": [name, value, ...], "children": [node, ...]}, character data becomes a string. The inverse shape of render.

Signature: xml\parse(s) → any · source

Parameter Type Optional Description
s string

Returns: any

auto-generatedxmlmodulestdlibmagusfile
Last updated (e0463131)
Earlier changes on this page (2)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.