pub struct Element {
pub name: String,
pub attributes: IndexMap<String, String>,
pub children: Vec<Element>,
pub text_content: String,
}
Expand description
An owned XML element, easy to create and/or manipulate.
Fields§
§name: String
§attributes: IndexMap<String, String>
§children: Vec<Element>
§text_content: String
Implementations§
source§impl Element
impl Element
pub fn new(name: impl ToString) -> Element
pub fn attr(&self, key: &str) -> Option<&str>
sourcepub fn child(&self, name: &str) -> Option<&Element>
pub fn child(&self, name: &str) -> Option<&Element>
Find the first child element with the given name.
sourcepub fn children<'a>(
&'a self,
name: &'a str
) -> impl Iterator<Item = &'a Element> + 'a
pub fn children<'a>( &'a self, name: &'a str ) -> impl Iterator<Item = &'a Element> + 'a
Iterate over all child elements with the given name.
pub fn set_attr(&mut self, key: impl ToString, value: impl ToString)
pub fn remove_attr(&mut self, key: &str) -> Option<String>
pub fn with_attr(self, key: impl ToString, value: impl ToString) -> Self
pub fn with_text(self, text: impl ToString) -> Self
pub fn with_child(self, element: Element) -> Self
Trait Implementations§
source§impl PartialEq for Element
impl PartialEq for Element
impl Eq for Element
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.