magus v0.4.2 is out. See what's new
¶ View generated markdown
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

generatedreference/buzz/xmlmodulestdlibmagusfile
Last updated (4f8cc295)
Earlier changes on this page (5)

Full history ↗ · Blame source ↗

Glossary

Magusfile

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

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Module

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

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Conventions

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