xml

An XML parser for Ecko: parse to a node tree, query by tag or path, extract text, and rebuild. Pure - no capabilities.

ecko get github.com/ecko-lang/xml
import xml

Pure computation: it declares no capabilities, so it cannot touch the network, the filesystem or the environment.

Version 0.9.5 - source - MIT.


parse(src)

Parse an XML document into a node tree. The root is a #root node whose children are the top-level elements; text becomes #text nodes.

text(node)

All text under a node, concatenated - the element's own text plus every descendant's, in document order. Returns "" for an element with no text.

find(node, path)

find(node, path) - a single tag matches descendants; "a/b/c" navigates: the first segment matches descendants, each further segment its children.

attr(node, name)

One attribute's value, or null when the node has no such attribute.

build(node)

build(node) -> an XML string (attrs sorted; empty elements self-close).