njs/xml
Types
Values
pub fn attr_value(
attr: XMLAttr,
name: String,
) -> Result(String, Nil)
pub fn c14n(root_node: a, excluding_node: b) -> buffer.Buffer
pub fn doc_tag(doc: XMLDoc, name: String) -> Result(XMLNode, Nil)
Returns the document root if its local name matches name.
pub fn exclusive_c14n(
root_node: a,
excluding_node: b,
with_comments: Bool,
prefix_list: String,
) -> buffer.Buffer
pub fn node_add_child(node: XMLNode, child: XMLNode) -> Nil
Adds a recursive copy of a namespace-free source. The source is unchanged. Mutation of a detached node, or copying a namespaced source, throws TypeError.
pub fn node_add_child_doc(node: XMLNode, child: XMLDoc) -> Nil
Adds a recursive copy of a namespace-free document’s root (njs 1.0.2+).
pub fn node_attr(
node: XMLNode,
name: String,
) -> Result(String, Nil)
Looks up an attribute by local name only. Use node_get_attribute_ns to
distinguish attributes with the same local name in different namespaces.
pub fn node_get_attribute_ns(
node: XMLNode,
namespace_uri: String,
local_name: String,
) -> Result(String, Nil)
Looks up an attribute by namespace URI and local name (njs 1.0.2+).
Use "" for no namespace. Unprefixed attributes have no namespace even
when their element declares a default namespace. Missing values are Error;
an attribute with an empty value is Ok("").
pub fn node_get_child_ns(
node: XMLNode,
namespace_uri: String,
local_name: String,
) -> Result(XMLNode, Nil)
Looks up a direct child by namespace URI and local name (njs 1.0.2+).
Use "" for no namespace. Returns Error(Nil) if no child matches.
pub fn node_parent(node: XMLNode) -> Result(XMLNode, Nil)
Returns Error(Nil) for a document root or a detached node.
pub fn node_remove_all_attributes(node: XMLNode) -> Nil
pub fn node_remove_all_children(node: XMLNode) -> Nil
pub fn node_remove_attribute(node: XMLNode, name: String) -> Nil
pub fn node_remove_children(
node: XMLNode,
tag_name: String,
) -> Nil
pub fn node_remove_tag(node: XMLNode, name: String) -> Nil
Deletes all children with this local name using delete node.$tag$name.
pub fn node_remove_text(node: XMLNode) -> Nil
pub fn node_set_attr(
node: XMLNode,
name: String,
value: String,
) -> Nil
pub fn node_set_tags(
node: XMLNode,
tags: array.Array(XMLNode),
) -> Nil
Replaces children with recursive copies. Sources must have no namespaces. Mutation of a detached node, or copying a namespaced source, throws TypeError.
pub fn node_set_text(node: XMLNode, value: String) -> Nil
pub fn node_tag(
node: XMLNode,
name: String,
) -> Result(XMLNode, Nil)
Looks up a child by local name, including names matching XMLNode methods.
pub fn node_tag_name(
node: XMLNode,
name: String,
) -> Result(XMLNode, Nil)
Alias for node_tag. Uses $tag$name so method names are safe too.
pub fn node_tags(node: XMLNode) -> array.Array(XMLNode)
Returns an empty array when the node has no child elements.
pub fn node_tags_name(
node: XMLNode,
name: String,
) -> array.Array(XMLNode)
Returns an empty array when there are no children with this local name.
pub fn serialize(
root_node: a,
excluding_node: b,
) -> buffer.Buffer
pub fn serialize_to_string(
root_node: a,
excluding_node: b,
) -> String