Skip to main content

XmlNode

Struct XmlNode 

Source
pub struct XmlNode { /* private fields */ }
Expand description

An XML element node handle. Cloning is cheap (Arc).

Implementations§

Source§

impl XmlNode

Source

pub fn new(name: &str) -> Self

Create a new named node

Source

pub fn empty() -> Self

Create an empty/null node

Source

pub fn is_empty(&self) -> bool

Check if this is the empty sentinel

Source

pub fn name(&self) -> String

Get the name of this node

Source

pub fn value(&self) -> String

Get the text value of this node

Source

pub fn set_name(&self, name: &str)

Set the name

Source

pub fn set_value(&self, value: &str)

Set the text value

Source

pub fn append_child(&self, name: &str) -> XmlNode

Append a child element with the given name, return the new child

Source

pub fn prepend_child(&self, name: &str) -> XmlNode

Prepend a child element

Source

pub fn append_child_value(&self, name: &str, value: &str) -> XmlNode

Append a child element with name and text value

Source

pub fn prepend_child_value(&self, name: &str, value: &str) -> XmlNode

Prepend a child element with name and text value

Source

pub fn set_child_value(&self, name: &str, value: &str) -> bool

Set the value of a named child (creating it if needed)

Source

pub fn child(&self, name: &str) -> XmlNode

Get a child by name

Source

pub fn child_value(&self, name: &str) -> String

Get the text value of a named child

Source

pub fn child_value_self(&self) -> String

Get the text content (value of first text child or self value)

Source

pub fn first_child(&self) -> XmlNode

Get the first child

Source

pub fn last_child(&self) -> XmlNode

Get the last child

Source

pub fn next_sibling(&self) -> XmlNode

Get next sibling (requires parent)

Source

pub fn next_sibling_named(&self, name: &str) -> XmlNode

Get next sibling with a given name

Source

pub fn previous_sibling(&self) -> XmlNode

Get previous sibling

Source

pub fn previous_sibling_named(&self, name: &str) -> XmlNode

Get previous sibling with a given name

Source

pub fn parent(&self) -> XmlNode

Get parent

Source

pub fn remove_child_named(&self, name: &str)

Remove a child by name

Source

pub fn remove_child(&self, child: &XmlNode)

Remove a specific child node

Source

pub fn deep_clone(&self) -> XmlNode

Deep clone (copy) of this subtree

Source

pub fn append_copy(&self, other: &XmlNode) -> XmlNode

Append a copy of another subtree

Source

pub fn prepend_copy(&self, other: &XmlNode) -> XmlNode

Prepend a copy of another subtree

Source

pub fn to_xml(&self) -> String

Serialize this subtree to XML string

Source

pub fn same_as(&self, other: &XmlNode) -> bool

Check pointer identity

Trait Implementations§

Source§

impl Clone for XmlNode

Source§

fn clone(&self) -> XmlNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for XmlNode

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.