pub struct Node<'a> {
pub doc: &'a Document,
pub id: NodeId,
}Expand description
A borrowed handle on a node.
Fields§
§doc: &'a Document§id: NodeIdImplementations§
Source§impl<'a> Node<'a>
impl<'a> Node<'a>
pub fn kind(&self) -> NodeKind
pub fn is_element(&self) -> bool
pub fn is_text(&self) -> bool
Sourcepub fn name(&self) -> &'a QName
pub fn name(&self) -> &'a QName
Element name. Panics on non-element non-PI nodes; use try_name.
pub fn try_name(&self) -> Option<&'a QName>
pub fn local(&self) -> &'a str
pub fn ns(&self) -> &'a str
pub fn is(&self, ns: &str, local: &str) -> bool
pub fn text_atom(&self) -> Option<&'a Atom>
pub fn parent(&self) -> Option<Node<'a>>
pub fn parent_element(&self) -> Option<Node<'a>>
pub fn first_child(&self) -> Option<Node<'a>>
pub fn last_child(&self) -> Option<Node<'a>>
pub fn next_sibling(&self) -> Option<Node<'a>>
pub fn prev_sibling(&self) -> Option<Node<'a>>
pub fn next_sibling_element(&self) -> Option<Node<'a>>
pub fn children(&self) -> Children<'a> ⓘ
Sourcepub fn elements_named(
&self,
ns: &'a str,
local: &'a str,
) -> impl Iterator<Item = Node<'a>> + 'a
pub fn elements_named( &self, ns: &'a str, local: &'a str, ) -> impl Iterator<Item = Node<'a>> + 'a
Child elements with the given name.
pub fn first_element_named(&self, ns: &str, local: &str) -> Option<Node<'a>>
Sourcepub fn descendants(&self) -> impl Iterator<Item = Node<'a>> + 'a
pub fn descendants(&self) -> impl Iterator<Item = Node<'a>> + 'a
Descendants (not including self) in document order.
Sourcepub fn descendants_or_self(&self) -> impl Iterator<Item = Node<'a>> + 'a
pub fn descendants_or_self(&self) -> impl Iterator<Item = Node<'a>> + 'a
Self and descendants in document order.
pub fn descendant_elements(&self) -> impl Iterator<Item = Node<'a>> + 'a
pub fn ancestors(&self) -> impl Iterator<Item = Node<'a>> + 'a
pub fn is_ancestor_of(&self, other: &Node<'_>) -> bool
pub fn attributes(&self) -> &'a [Attribute]
Sourcepub fn att(&self, local: &str) -> Option<&'a str>
pub fn att(&self, local: &str) -> Option<&'a str>
Unqualified attribute value (attr("", local)).
pub fn attr_atom(&self, ns: &str, local: &str) -> Option<&'a Atom>
Sourcepub fn lookup_namespace(&self, prefix: &str) -> Option<&'a str>
pub fn lookup_namespace(&self, prefix: &str) -> Option<&'a str>
Resolve a prefix (“” = default namespace) in scope at this node.
Sourcepub fn lookup_prefix(&self, ns: &str) -> Option<&'a str>
pub fn lookup_prefix(&self, ns: &str) -> Option<&'a str>
Prefix bound to a namespace in scope here (first found walking up).
Sourcepub fn in_scope_namespaces(&self) -> Vec<(Atom, Atom)>
pub fn in_scope_namespaces(&self) -> Vec<(Atom, Atom)>
All in-scope namespace bindings (prefix, uri), nearest wins; excludes undeclarations.
Sourcepub fn resolve_qname(&self, lexical: &str, use_default: bool) -> Option<QName>
pub fn resolve_qname(&self, lexical: &str, use_default: bool) -> Option<QName>
Resolve a lexical QName (p:local or local) using the in-scope namespaces.
Unprefixed names take the default namespace when use_default is set (XSD QName
content does; attribute names do not).
Sourcepub fn string_value(&self) -> String
pub fn string_value(&self) -> String
Concatenated descendant text (XPath string value).
Sourcepub fn child_text(&self) -> String
pub fn child_text(&self) -> String
Text of the direct text children only.
pub fn offset(&self) -> u32
pub fn line(&self) -> u32
pub fn line_col(&self) -> (u32, u32)
Sourcepub fn element_index(&self) -> usize
pub fn element_index(&self) -> usize
Position among sibling elements (1-based), as used by XPointer element schemes.