pub struct ETree { /* private fields */ }Expand description
Element tree
etree.ETree stores a sequence of etree.ETreeNode.
Implementations
sourceimpl ETree
impl ETree
pub fn parse_file<P: AsRef<Path>>(path: P) -> ETree
pub fn parse_str(content: &str) -> ETree
pub fn write_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
sourcepub fn get_enable_index(&self) -> bool
pub fn get_enable_index(&self) -> bool
get whether index feature is enabled
sourcepub fn set_enable_index(&mut self, enable_index: bool)
pub fn set_enable_index(&mut self, enable_index: bool)
set whether index feature is enabled (usable for function pos())
sourcepub fn get_version(&self) -> Option<String>
pub fn get_version(&self) -> Option<String>
get XML version
sourcepub fn set_version(&mut self, version: &str)
pub fn set_version(&mut self, version: &str)
set XML version
sourcepub fn get_encoding(&self) -> Option<String>
pub fn get_encoding(&self) -> Option<String>
get XML encoding
sourcepub fn set_encoding(&mut self, encoding: &str)
pub fn set_encoding(&mut self, encoding: &str)
set XML encoding
sourcepub fn get_standalone(&self) -> Option<String>
pub fn get_standalone(&self) -> Option<String>
get XML standalone
sourcepub fn set_standalone(&mut self, standalone: &str)
pub fn set_standalone(&mut self, standalone: &str)
set XML standalone
sourcepub fn children(&self, pos: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn children(&self, pos: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
get positions of children node
sourcepub fn children_by_name(&self, pos: usize, tagname: &str) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn children_by_name(&self, pos: usize, tagname: &str) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
get positions of children node with specified name
sourcepub fn descendant(&self, pos: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn descendant(&self, pos: usize) -> Vec<usize>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
get positions of descendant node
sourcepub fn subtree(&self, pos: usize) -> ETree
pub fn subtree(&self, pos: usize) -> ETree
clone a subtree rooted at the node of specified position
sourcepub fn append_previous_node(
&mut self,
pos: usize,
node: ETreeNode
) -> Option<usize>
pub fn append_previous_node(
&mut self,
pos: usize,
node: ETreeNode
) -> Option<usize>
append sibling node before the node of specified position and return the position of sibling node
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn append_next_node(&mut self, pos: usize, node: ETreeNode) -> Option<usize>
pub fn append_next_node(&mut self, pos: usize, node: ETreeNode) -> Option<usize>
append sibling node after the node of specified position and return the position of sibling node
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn append_child_node(&mut self, pos: usize, node: ETreeNode) -> Option<usize>
pub fn append_child_node(&mut self, pos: usize, node: ETreeNode) -> Option<usize>
append child node below the node of specified position and return the position of child node
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn append_previous_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
pub fn append_previous_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
append sibling tree before the node of specified position and return the position of sibling tree
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn append_next_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
pub fn append_next_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
append sibling tree after the node of specified position and return the position of sibling tree
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn append_child_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
pub fn append_child_tree(&mut self, pos: usize, tree: ETree) -> Option<usize>
append child tree below the node of specified position and return the position of child tree
Warning: position which is larger than return value and obtained before this function all should be re-obtained
sourcepub fn remove(&mut self, pos: usize)
pub fn remove(&mut self, pos: usize)
remove a subtree rooted at the node of specified position
Warning: position which is larger than specified value and obtained before this function all should be re-obtained
sourcepub fn find(&self, path: &str) -> Option<usize>
pub fn find(&self, path: &str) -> Option<usize>
find the first node that matches path from the root node
sourcepub fn find_at(&self, path: &str, pos: usize) -> Option<usize>
pub fn find_at(&self, path: &str, pos: usize) -> Option<usize>
find the first node that matches path from specified node
sourcepub fn find_iter(&self, path: &str) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
pub fn find_iter(&self, path: &str) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
find nodes that matches path from the root node
sourcepub fn find_at_iter(&self, path: &str, pos: usize) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
pub fn find_at_iter(&self, path: &str, pos: usize) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
find nodes that matches path from specified node
sourcepub fn rfind(&self, path: &str) -> Option<usize>
pub fn rfind(&self, path: &str) -> Option<usize>
find the last node that matches path from the root node
sourcepub fn rfind_at(&self, path: &str, pos: usize) -> Option<usize>
pub fn rfind_at(&self, path: &str, pos: usize) -> Option<usize>
find the last node that matches path from specified node
sourcepub fn rfind_iter(&self, path: &str) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
pub fn rfind_iter(&self, path: &str) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
find nodes in reverse order that matches path from the root node
sourcepub fn rfind_at_iter(&self, path: &str, pos: usize) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
pub fn rfind_at_iter(&self, path: &str, pos: usize) -> XPathIterator<'_>ⓘNotable traits for XPathIterator<'a>impl<'a> Iterator for XPathIterator<'a> type Item = usize;
find nodes in reverse order that matches path from specified node