mixin

Funcs

Funcs : Funcs

meta mixin slots xmlRead

Parse an XML document from an I/O handle and return root element

xmlName

Get the unqualified local name of an element or attribute

xmlQname

Get the qualified local name of an element or attribute which includes both its prefix and unqualified name

xmlPrefix

Get the namespace prefix of an element or attribute

xmlNs

Get the namespace URI of an element or attribute

xmlVal

If node is an attribute, then return its value string

xmlAttr

Get an attribute from an element by its non-qualified local name

xmlAttrs

Get list of all an elements attributes

xmlElem

Find an element by its non-qualified local name

xmlElems

Get the children elements

xmlRead (handle: Obj?) => XElem <admin>

Parse an XML document from an I/O handle and return root element.

Examples:

xmlRead("<foo/>")
xmlRead(`io/test.xml`)

xmlName (node: Obj) => Str

Get the unqualified local name of an element or attribute:

<foo>    >>  "foo"
<x:foo>  >>  "foo"

xmlQname (node: Obj) => Str

Get the qualified local name of an element or attribute which includes both its prefix and unqualified name:

<foo>    >>  "foo"
<x:foo>  >>  "x:foo"

xmlPrefix (node: Obj) => Str?

Get the namespace prefix of an element or attribute. If node is an element in the default namespace then return "". If no namespace is specified return null.

Examples:

<foo>               >>  null
<x:foo>             >>  "x"
<foo xmlns='...'/>  >>  ""

xmlNs (node: Obj) => Uri?

Get the namespace URI of an element or attribute. If no namespace was specified return null.

Example:

xmlRead("<foo xmlns='bar'/>").xmlNs  >>  `bar`

xmlVal (node: Obj?) => Str?

If node is an attribute, then return its value string. If node is an element return its first text child node, otherwise null. If node is null, then return null.

Examples:

xmlRead("<x/>").xmlVal                      >>  null
xmlRead("<x>hi</x>").xmlVal                 >>  "hi"
xmlRead("<x a='v'/>").xmlAttr("a").xmlVal   >>  "v"
xmlRead("<x/>").xmlAttr("a", false).xmlVal  >>  null

xmlAttr (elem: XElem, name: Str, checked: Bool) => XAttr?

Get an attribute from an element by its non-qualified local name. If the attribute is not found and checked is false then return null otherwise throw XErr.

Examples:

xmlRead("<x a='v'/>").xmlAttr("a").xmlVal   >>  "v"
xmlRead("<x/>").xmlAttr("a", false).xmlVal  >>  null

xmlAttrs (elem: XElem) => List

Get list of all an elements attributes.

Example:

attrs: xmlRead("<x a='' b=''/>").xmlAttrs
attrs.map(xmlName)  >>  ["a", "b"]

xmlElem (elem: XElem, name: Str, checked: Bool) => XElem?

Find an element by its non-qualified local name. If there are multiple child elements with the name, then the first one is returned. If the element is not found and checked is false then return null otherwise throw XErr.

Example:

xmlRead("<d><a/></d>").xmlElem("a")

xmlElems (elem: XElem) => List

Get the children elements. If this element contains text or PI nodes, then they are excluded in the result.

Example:

elems: xmlRead("<d><a/><b/></d>").xmlElems
elems.map(xmlName)  >>  ["a", "b"]

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST