pub struct XmlElement { /* private fields */ }Expand description
An XML element with a qualified name and attributes.
Implementations§
Source§impl XmlElement
impl XmlElement
Sourcepub fn new(name: String, attributes: HashMap<String, String>) -> Self
pub fn new(name: String, attributes: HashMap<String, String>) -> Self
Creates a new XML element with the given name and attributes.
Sourcepub fn new_with_namespace(
name: String,
expanded_name: Option<ExpandedName>,
namespace_decls: HashMap<String, String>,
attributes: HashMap<String, String>,
) -> Self
pub fn new_with_namespace( name: String, expanded_name: Option<ExpandedName>, namespace_decls: HashMap<String, String>, attributes: HashMap<String, String>, ) -> Self
Creates a new element with namespace information.
Sourcepub fn rehash(&mut self)
pub fn rehash(&mut self)
Recalculates the hash values and info size.
This should be called after modifying the name or attributes.
Sourcepub fn set_qname(&mut self, name: String)
pub fn set_qname(&mut self, name: String)
Sets the qualified name of the element.
Note: This does not automatically rehash. Call rehash() after
modifying if hash values are needed.
Sourcepub fn attributes(&self) -> &HashMap<String, String>
pub fn attributes(&self) -> &HashMap<String, String>
Returns the attributes.
Sourcepub fn attributes_mut(&mut self) -> &mut HashMap<String, String>
pub fn attributes_mut(&mut self) -> &mut HashMap<String, String>
Returns a mutable reference to the attributes.
Note: This does not automatically rehash. Call rehash() after
modifying if hash values are needed.
Sourcepub fn set_attributes(&mut self, attributes: HashMap<String, String>)
pub fn set_attributes(&mut self, attributes: HashMap<String, String>)
Sets the attributes.
Note: This does not automatically rehash. Call rehash() after
modifying if hash values are needed.
Sourcepub fn expanded_name(&self) -> Option<&ExpandedName>
pub fn expanded_name(&self) -> Option<&ExpandedName>
Returns the expanded name, if available.
Sourcepub fn namespace_decls(&self) -> &HashMap<String, String>
pub fn namespace_decls(&self) -> &HashMap<String, String>
Returns namespace declarations on this element.
Sourcepub fn names_match(&self, other: &XmlElement) -> bool
pub fn names_match(&self, other: &XmlElement) -> bool
Compares element names with namespace awareness. Falls back to string comparison if neither has expanded names.
Sourcepub fn content_equals(&self, other: &XmlElement) -> bool
pub fn content_equals(&self, other: &XmlElement) -> bool
Tests content equality using hash comparison.
Note: This compares element name and attributes only, not namespace
declarations. Use namespace_decls_equal for namespace comparison.
Sourcepub fn namespace_decls_equal(&self, other: &XmlElement) -> bool
pub fn namespace_decls_equal(&self, other: &XmlElement) -> bool
Tests whether namespace declarations are equal.
Sourcepub fn content_hash(&self) -> i32
pub fn content_hash(&self) -> i32
Returns a 32-bit hash code for this element.
Trait Implementations§
Source§impl Clone for XmlElement
impl Clone for XmlElement
Source§fn clone(&self) -> XmlElement
fn clone(&self) -> XmlElement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more