Skip to main content

Node

Struct Node 

Source
pub struct Node<'a> {
    pub doc: &'a Document,
    pub id: NodeId,
}
Expand description

A borrowed handle on a node.

Fields§

§doc: &'a Document§id: NodeId

Implementations§

Source§

impl<'a> Node<'a>

Source

pub fn kind(&self) -> NodeKind

Source

pub fn is_element(&self) -> bool

Source

pub fn is_text(&self) -> bool

Source

pub fn name(&self) -> &'a QName

Element name. Panics on non-element non-PI nodes; use try_name.

Source

pub fn try_name(&self) -> Option<&'a QName>

Source

pub fn local(&self) -> &'a str

Source

pub fn ns(&self) -> &'a str

Source

pub fn is(&self, ns: &str, local: &str) -> bool

Source

pub fn text(&self) -> Option<&'a str>

Text, comment or PI content.

Source

pub fn text_atom(&self) -> Option<&'a Atom>

Source

pub fn parent(&self) -> Option<Node<'a>>

Source

pub fn parent_element(&self) -> Option<Node<'a>>

Source

pub fn first_child(&self) -> Option<Node<'a>>

Source

pub fn last_child(&self) -> Option<Node<'a>>

Source

pub fn next_sibling(&self) -> Option<Node<'a>>

Source

pub fn prev_sibling(&self) -> Option<Node<'a>>

Source

pub fn next_sibling_element(&self) -> Option<Node<'a>>

Source

pub fn children(&self) -> Children<'a> ⓘ

Source

pub fn elements(&self) -> impl Iterator<Item = Node<'a>> + 'a

Child elements.

Source

pub fn elements_named( &self, ns: &'a str, local: &'a str, ) -> impl Iterator<Item = Node<'a>> + 'a

Child elements with the given name.

Source

pub fn first_element_named(&self, ns: &str, local: &str) -> Option<Node<'a>>

Source

pub fn descendants(&self) -> impl Iterator<Item = Node<'a>> + 'a

Descendants (not including self) in document order.

Source

pub fn descendants_or_self(&self) -> impl Iterator<Item = Node<'a>> + 'a

Self and descendants in document order.

Source

pub fn descendant_elements(&self) -> impl Iterator<Item = Node<'a>> + 'a

Source

pub fn ancestors(&self) -> impl Iterator<Item = Node<'a>> + 'a

Source

pub fn is_ancestor_of(&self, other: &Node<'_>) -> bool

Source

pub fn attributes(&self) -> &'a [Attribute]

Source

pub fn attr(&self, ns: &str, local: &str) -> Option<&'a str>

Attribute value by expanded name.

Source

pub fn att(&self, local: &str) -> Option<&'a str>

Unqualified attribute value (attr("", local)).

Source

pub fn attr_atom(&self, ns: &str, local: &str) -> Option<&'a Atom>

Source

pub fn ns_decls(&self) -> &'a [(Atom, Atom)]

Namespace declarations on this element.

Source

pub fn lookup_namespace(&self, prefix: &str) -> Option<&'a str>

Resolve a prefix (“” = default namespace) in scope at this node.

Source

pub fn lookup_prefix(&self, ns: &str) -> Option<&'a str>

Prefix bound to a namespace in scope here (first found walking up).

Source

pub fn in_scope_namespaces(&self) -> Vec<(Atom, Atom)>

All in-scope namespace bindings (prefix, uri), nearest wins; excludes undeclarations.

Source

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).

Source

pub fn string_value(&self) -> String

Concatenated descendant text (XPath string value).

Source

pub fn child_text(&self) -> String

Text of the direct text children only.

Source

pub fn base_uri(&self) -> String

Base URI after applying xml:base attributes up the tree.

Source

pub fn lang(&self) -> Option<&'a str>

Inherited xml:lang.

Source

pub fn offset(&self) -> u32

Source

pub fn line(&self) -> u32

Source

pub fn line_col(&self) -> (u32, u32)

Source

pub fn element_index(&self) -> usize

Position among sibling elements (1-based), as used by XPointer element schemes.

Source

pub fn to_xml(&self) -> String

Serialize this subtree back to XML (for fragments such as segments and footnotes).

Trait Implementations§

Source§

impl<'a> Clone for Node<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Node<'a>

Source§

impl Debug for Node<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Node<'_>

Source§

impl PartialEq for Node<'_>

Source§

fn eq(&self, o: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<'a> Forget for Node<'a>

§

impl<'a> Freeze for Node<'a>
where &'a Document: Freeze,

§

impl<'a> Move for Node<'a>

§

impl<'a> RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>
where &'a Document: Send,

§

impl<'a> Sync for Node<'a>
where Arc<str>: Sync, RawVecInner: Sync, RawTable<(Arc<str>, NodeId)>: Sync,

§

impl<'a> Unpin for Node<'a>
where &'a Document: Unpin,

§

impl<'a> UnsafeUnpin for Node<'a>
where &'a Document: UnsafeUnpin,

§

impl<'a> UnwindSafe for Node<'a>
where &'a Document: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.