xml
39 items · generated by scribe fromstdlib/xml.fd· synced 2026-11-15
Contents
- XmlNode (struct)
- xml_unescape (function)
- xml_escape (function)
- XmlDoc (struct)
- xml_parse (function)
- xml_parse_fragment (function)
- xml_load (function)
- xml_attr (function)
- xml_child (function)
- xml_has (function)
- xml_children (function)
- xml_find_all (function)
- xml_text (function)
- xml_to_str (function)
- xml_elem (function)
- xml_with_attr (function)
- xml_with_child (function)
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:
| Name | Type |
|---|---|
tag | str |
attr_names | Vec<str> |
attr_vals | Vec<str> |
text | str |
children | Vec<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:
| Name | Type |
|---|---|
ok | bool |
error | str |
root | XmlNode |
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:XmlNodename: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:XmlNodetag: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:XmlNodetag: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:XmlNodetag: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:XmlNodetag: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:strtext: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:XmlNodename:strvalue: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:XmlNodechild:XmlNode
Returns: XmlNode
Defined at line 1026
Generated by scribe, the Fides documentation generator