pub struct XmlElement {
pub name: String,
pub attributes: HashMap<String, String>,
pub text_content: Option<String>,
pub children: Vec<XmlElement>,
}Expand description
XML元素信息
Fields§
§name: String§attributes: HashMap<String, String>§text_content: Option<String>§children: Vec<XmlElement>Implementations§
Source§impl XmlElement
impl XmlElement
Sourcepub fn get_attribute(&self, name: &str) -> Option<&String>
pub fn get_attribute(&self, name: &str) -> Option<&String>
获取属性值
Sourcepub fn set_text_content<S: AsRef<str>>(&mut self, content: S)
pub fn set_text_content<S: AsRef<str>>(&mut self, content: S)
设置文本内容
Sourcepub fn add_child(&mut self, child: XmlElement)
pub fn add_child(&mut self, child: XmlElement)
添加子元素
Sourcepub fn find_child(&self, name: &str) -> Option<&XmlElement>
pub fn find_child(&self, name: &str) -> Option<&XmlElement>
查找第一个匹配名称的子元素
Sourcepub fn find_children(&self, name: &str) -> Vec<&XmlElement>
pub fn find_children(&self, name: &str) -> Vec<&XmlElement>
查找所有匹配名称的子元素
Sourcepub fn find_element_recursive(&self, name: &str) -> Option<&XmlElement>
pub fn find_element_recursive(&self, name: &str) -> Option<&XmlElement>
递归查找元素(深度优先搜索)
Trait Implementations§
Source§impl Clone for XmlElement
impl Clone for XmlElement
Source§fn clone(&self) -> XmlElement
fn clone(&self) -> XmlElement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for XmlElement
impl RefUnwindSafe for XmlElement
impl Send for XmlElement
impl Sync for XmlElement
impl Unpin for XmlElement
impl UnsafeUnpin for XmlElement
impl UnwindSafe for XmlElement
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