[−][src]Struct lsl::XMLElement
A lightweight XML element tree; models the .desc()
field of StreamInfo
.
This class can be tought of as a "cursor" in an XML document owned by the StreamInfo
, which
provides operations for navigating to parent, children and sibling elements, as well as modification
operations for inserting or removing content. Each element has a name and can have multiple named
children or have text content as value; attributes are omitted. Most operations return a node,
which allows you to chain multiple operations. The API is modeled after a subset of pugixml's node
type and is compatible with it. See also here for
additional documentation.
Note: operations on non-existent nodes become safe no-ops instead of returning error variants
or crashing. Since in most cases you will be writing data instead of navigating the tree and/or
reading, you will rarely encounter this. You can rely on the is_valid()
method to check the
validity of the current element.
Examples: the *advanced.rs
examples (found in the crate's github repository) illustrate the
use of XMLElement
cursors.
Panics: any strings passed into this function must be valid UTF8-encoded strings and contain no intermittent zero bytes (otherwise this will trigger an assertion).
Implementations
impl XMLElement
[src]
pub fn first_child(&self) -> XMLElement
[src]
Get the first child of the element.
pub fn last_child(&self) -> XMLElement
[src]
Get the last child of the element.
pub fn next_sibling(&self) -> XMLElement
[src]
Get the next sibling in the children list of the parent node.
pub fn previous_sibling(&self) -> XMLElement
[src]
Get the previous sibling in the children list of the parent node.
pub fn parent(&self) -> XMLElement
[src]
Get the parent node.
pub fn child(&self, name: &str) -> XMLElement
[src]
Get a child with a specified name.
pub fn next_sibling_named(&self, name: &str) -> XMLElement
[src]
Get the next sibling with the specified name.
pub fn previous_sibling_named(&self, name: &str) -> XMLElement
[src]
Get the previous sibling with the specified name.
pub fn empty(&self) -> bool
[src]
Whether this node is empty.
pub fn is_text(&self) -> bool
[src]
Whether this is a text body (instead of an XML element). True both for plain char data and CData.
pub fn name(&self) -> String
[src]
Name of the element.
pub fn value(&self) -> String
[src]
Value of the element.
pub fn child_value(&self) -> String
[src]
Get child value (value of the first child that is text).
pub fn child_value_named(&self, name: &str) -> String
[src]
Get child value of a child with a specified name.
pub fn append_child_value(&mut self, name: &str, value: &str) -> XMLElement
[src]
Append a child node with a given name, and give it a (nameless) plain-text child with the given text value.
Returns the same element on which the operation was performed (not the child).
pub fn prepend_child_value(&mut self, name: &str, value: &str) -> XMLElement
[src]
Prepend a child node with a given name and give it a (nameless) plain-text child with the given text value.
Returns the same element on which the operation was performed (not the child).
pub fn set_child_value(&mut self, name: &str, value: &str) -> bool
[src]
Set the text value of the (nameless) plain-text child of a named child node.
pub fn set_name(&mut self, rhs: &str) -> bool
[src]
Set the element's name. Returns false if the node is empty (or if out of memory).
pub fn set_value(&mut self, rhs: &str) -> bool
[src]
Set the element's value. Returns false if the node is empty (or if out of memory).
pub fn append_child(&mut self, name: &str) -> XMLElement
[src]
Append a child element with the specified name and return it.
pub fn prepend_child(&mut self, name: &str) -> XMLElement
[src]
Prepend a child element with the specified name and return it.
pub fn append_copy(&mut self, e: XMLElement) -> XMLElement
[src]
Append a copy of the specified element as a child and return a cursor to the result.
pub fn prepend_copy(&mut self, e: XMLElement) -> XMLElement
[src]
Prepend a child element with the specified name and return a cursor to the result.
pub fn remove_child(&mut self, e: XMLElement)
[src]
Remove a specified child element.
pub fn remove_child_named(&mut self, name: &str)
[src]
Remove a child element with the specified name.
pub fn is_valid(&self) -> bool
[src]
Returns true if the current node is valid, false otherwise
Trait Implementations
impl Clone for XMLElement
[src]
fn clone(&self) -> XMLElement
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for XMLElement
[src]
impl Display for XMLElement
[src]
Auto Trait Implementations
impl !RefUnwindSafe for XMLElement
impl !Send for XMLElement
impl !Sync for XMLElement
impl Unpin for XMLElement
impl UnwindSafe for XMLElement
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,