pub struct Node {
pub name: String,
pub text: String,
pub children: Vec<Node>,
}Expand description
A lightweight XML tree node.
Fields§
§name: StringElement name.
text: StringDirect text content (trimmed).
children: Vec<Node>Child nodes in document order.
Implementations§
Source§impl Node
impl Node
Sourcepub fn child(&self, name: &str) -> Option<&Node>
pub fn child(&self, name: &str) -> Option<&Node>
Find the first direct child element with the given name.
Sourcepub fn children_named<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a Node> + 'a
pub fn children_named<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = &'a Node> + 'a
Collect children with the given name.
Sourcepub fn child_text<'a>(&'a self, name: &str) -> &'a str
pub fn child_text<'a>(&'a self, name: &str) -> &'a str
Text content of the named child, default empty.
Sourcepub fn child_bool(&self, name: &str) -> bool
pub fn child_bool(&self, name: &str) -> bool
Parse text of named child as boolean (true / false).
Sourcepub fn items_named<'a>(
&'a self,
wrapper: &'a str,
item_name: &'a str,
) -> Vec<&'a Node>
pub fn items_named<'a>( &'a self, wrapper: &'a str, item_name: &'a str, ) -> Vec<&'a Node>
Parse a <Wrapper><Quantity/><Items>...</Items></Wrapper> list shape.
Sourcepub fn string_items(&self, wrapper: &str, item_name: &str) -> Vec<String>
pub fn string_items(&self, wrapper: &str, item_name: &str) -> Vec<String>
Parse a <Wrapper><Items>...</Items></Wrapper> list of string contents.
Sourcepub fn direct_items<'a>(&'a self, item_name: &'a str) -> Vec<&'a Node>
pub fn direct_items<'a>(&'a self, item_name: &'a str) -> Vec<&'a Node>
Parse a <Items>...<Item/>...</Items> list where Items is a direct child.
Use this when you have already descended into the wrapper node and the
current node looks like <Wrapper><Quantity/><Items><Item/></Items></Wrapper>.
Sourcepub fn direct_string_items(&self, item_name: &str) -> Vec<String>
pub fn direct_string_items(&self, item_name: &str) -> Vec<String>
String variant of direct_items: returns the text of every matching item.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more