Skip to content

stdlib/xmlView source ↗

xml

39 items · generated by scribe fromstdlib/xml.fd· synced 2026-11-15

stdlib/xml39 items

Contents

XmlNode

An XML element. text accumulates character data found directly inside the element (concatenated, entity-decoded). Empty tag marks a parse failure / not-found sentinel.

pub struct XmlNode {

Fields:

NameType
tagstr
attr_namesVec<str>
attr_valsVec<str>
textstr
childrenVec<XmlNode>

Defined at line 46


xml_unescape

Decode & < > ” ’ &#NN; &#xHH; entities.

pub fn xml_unescape(s: str) -> str {

Parameters:

  • s: str

Returns: str

Defined at line 67


xml_escape

Escape & < > ” in text content.

pub fn xml_escape(s: str) -> str {

Parameters:

  • s: str

Returns: str

Defined at line 135


XmlDoc

A strictly parsed document: root is the document element, or ok = false and error says what is not well-formed and where.

pub struct XmlDoc {

Fields:

NameType
okbool
errorstr
rootXmlNode

Defined at line 164


xml_parse

Parse an XML document leniently (malformed parts are skipped or kept as text). Returns the root element; a node with tag "" when no element is found.

pub fn xml_parse(text: str) -> XmlNode {

Parameters:

  • text: str

Returns: XmlNode

Defined at line 878


xml_parse_fragment

Parse a fragment allowing multiple top-level elements.

pub fn xml_parse_fragment(text: str) -> Vec<XmlNode> {

Parameters:

  • text: str

Returns: Vec<XmlNode>

Defined at line 888


xml_load

Parse a document strictly: it must be well-formed XML 1.0 (see the module header); otherwise ok = false and error gives the line and column of the first problem.

pub fn xml_load(text: str) -> XmlDoc {

Parameters:

  • text: str

Returns: XmlDoc

Defined at line 897


xml_attr

Attribute value or "" when absent.

pub fn xml_attr(node: XmlNode, name: str) -> str {

Parameters:

  • node: XmlNode
  • name: str

Returns: str

Defined at line 913


xml_child

First direct child with tag; tag "" sentinel when absent.

pub fn xml_child(node: XmlNode, tag: str) -> XmlNode {

Parameters:

  • node: XmlNode
  • tag: str

Returns: XmlNode

Defined at line 925


xml_has

True when node has a direct child with tag.

pub fn xml_has(node: XmlNode, tag: str) -> bool {

Parameters:

  • node: XmlNode
  • tag: str

Returns: bool

Defined at line 937


xml_children

All direct children with tag.

pub fn xml_children(node: XmlNode, tag: str) -> Vec<XmlNode> {

Parameters:

  • node: XmlNode
  • tag: str

Returns: Vec<XmlNode>

Defined at line 942


xml_find_all

All descendant elements with tag (document order).

pub fn xml_find_all(node: XmlNode, tag: str) -> Vec<XmlNode> {

Parameters:

  • node: XmlNode
  • tag: str

Returns: Vec<XmlNode>

Defined at line 955


xml_text

All descendant-or-self text concatenated (entity-decoded).

pub fn xml_text(node: XmlNode) -> str {

Parameters:

  • node: XmlNode

Returns: str

Defined at line 973


xml_to_str

Serialize a node tree back to XML text (no pretty indentation).

pub fn xml_to_str(node: XmlNode) -> str {

Parameters:

  • node: XmlNode

Returns: str

Defined at line 990


xml_elem

Build an element node.

pub fn xml_elem(tag: str, text: str) -> XmlNode {

Parameters:

  • tag: str
  • text: str

Returns: XmlNode

Defined at line 1011


xml_with_attr

Add an attribute to a node (returns the node for chaining).

pub fn xml_with_attr(node: XmlNode, name: str, value: str) -> XmlNode {

Parameters:

  • node: XmlNode
  • name: str
  • value: str

Returns: XmlNode

Defined at line 1018


xml_with_child

Append a child (returns the parent for chaining).

pub fn xml_with_child(node: XmlNode, child: XmlNode) -> XmlNode {

Parameters:

  • node: XmlNode
  • child: XmlNode

Returns: XmlNode

Defined at line 1026


Generated by scribe, the Fides documentation generator