pub struct Element {
pub prefix: Option<String>,
pub name: String,
pub attributes: HashMap<String, String>,
pub children: Vec<Element>,
pub text: Option<String>,
pub cdata: Option<String>,
}Expand description
An XML element
Fields§
§prefix: Option<String>Tag prefix, used for namespacing: xsl in xsl:for-each
name: StringTag name: for-each in xsl:for-each
attributes: HashMap<String, String>Tag attributes
children: Vec<Element>A vector of child elements
text: Option<String>Contents of the element
cdata: Option<String>CDATA contents of the element
Implementations§
Source§impl Element
impl Element
Sourcepub fn new<S>(name: S) -> Elementwhere
S: ToString,
pub fn new<S>(name: S) -> Elementwhere
S: ToString,
Create a new Element with the tag name name
Sourcepub fn find_child<P>(&self, predicate: P) -> Option<&Element>
pub fn find_child<P>(&self, predicate: P) -> Option<&Element>
Find a single child of the current Element, given a predicate
Sourcepub fn find_child_mut<P>(&mut self, predicate: P) -> Option<&mut Element>
pub fn find_child_mut<P>(&mut self, predicate: P) -> Option<&mut Element>
Find a single child of the current Element, given a predicate; returns a mutable borrow
Sourcepub fn find(&self, path: &str) -> Result<&Element, Error>
pub fn find(&self, path: &str) -> Result<&Element, Error>
Traverse element using an xpath-like string: root/child/a
pub fn find_value<T: FromStr>(&self, path: &str) -> Result<Option<T>, Error>
Sourcepub fn filter_children<P>(&self, predicate: P) -> Filter<Iter<'_, Element>, P>
pub fn filter_children<P>(&self, predicate: P) -> Filter<Iter<'_, Element>, P>
Filters the children of the current Element, given a predicate
Trait Implementations§
Source§impl From<Element> for ElementBuilder
impl From<Element> for ElementBuilder
Source§fn from(element: Element) -> ElementBuilder
fn from(element: Element) -> ElementBuilder
Converts to this type from the input type.
Source§impl From<ElementBuilder> for Element
impl From<ElementBuilder> for Element
Source§fn from(value: ElementBuilder) -> Element
fn from(value: ElementBuilder) -> Element
Converts to this type from the input type.
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