pub struct XmlElement {
pub tag: String,
pub local_name: String,
pub namespace: Option<String>,
pub attributes: HashMap<String, String>,
pub children: Vec<XmlElement>,
pub text: String,
}Expand description
Represents an XML element with attributes and children
Fields§
§tag: StringElement tag name (with namespace prefix if present)
local_name: StringLocal name without namespace prefix
namespace: Option<String>Namespace URI
attributes: HashMap<String, String>Element attributes
children: Vec<XmlElement>Child elements
text: StringText content
Implementations§
Source§impl XmlElement
impl XmlElement
Sourcepub fn with_namespace(tag: &str, namespace: &str) -> Self
pub fn with_namespace(tag: &str, namespace: &str) -> Self
Create element with namespace
Sourcepub fn add_child(&mut self, child: XmlElement)
pub fn add_child(&mut self, child: XmlElement)
Add child element
Sourcepub fn find(&self, local_name: &str) -> Option<&XmlElement>
pub fn find(&self, local_name: &str) -> Option<&XmlElement>
Find first child by local name
Sourcepub fn find_all(&self, local_name: &str) -> Vec<&XmlElement>
pub fn find_all(&self, local_name: &str) -> Vec<&XmlElement>
Find all children by local name
Sourcepub fn find_descendant(&self, local_name: &str) -> Option<&XmlElement>
pub fn find_descendant(&self, local_name: &str) -> Option<&XmlElement>
Find first descendant by local name (recursive)
Sourcepub fn find_all_descendants(&self, local_name: &str) -> Vec<&XmlElement>
pub fn find_all_descendants(&self, local_name: &str) -> Vec<&XmlElement>
Find all descendants by local name (recursive)
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Get all text content recursively
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 · 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 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