std::encoding::xmlXML parsing and manipulation.
Parse XML strings into node trees, inspect elements, extract attributes and text content, and serialize back to XML text.
import std.encoding.xml;
fn main() {
let root = match xml.parse("<book><title>Hew Guide</title></book>") {
.Ok(node) => node,
.Err(reason) => panic(reason),
};
let title = root.get_child(0);
println(title.get_text());
title.close();
root.close();
}
parseParse an XML string without panicking.
Returns the parsed Node on success or the parser's error message when
s is not well-formed XML.
is_wellformedReport whether s is well-formed XML, without constructing a Node.
Prefer parse(s) when the parsed node or error message is needed.
to_stringSerialize a Node tree back to an XML string.
get_attributeGet an attribute value from a node. Returns empty string if not found.
get_textGet the concatenated text content of a node and its descendants.
NodeNodeMethodsMethods available on an XML Node.
Serialize the node tree back to an XML string.
Get the tag name of an element node. Returns empty for text nodes.
Get an attribute value by name. Returns empty string if not found.
Get the number of child nodes.
Get a child node by index. Returns a new Node that must be freed.
Get the concatenated text content of this node and its descendants.
Return 1 if this is an element node, 0 if text, -1 if null.