pub struct XmlNode { /* private fields */ }Expand description
A reference to a node within a document.
This is a lightweight handle that can be used to access node data through the document.
Implementations§
Source§impl XmlNode
impl XmlNode
Sourcepub fn get_prefix(&self) -> Option<String>
pub fn get_prefix(&self) -> Option<String>
Returns the namespace prefix (if any).
Sourcepub fn get_namespace_uri(&self) -> Option<String>
pub fn get_namespace_uri(&self) -> Option<String>
Returns the namespace URI (if any).
Sourcepub fn get_namespace(&self) -> Option<Namespace>
pub fn get_namespace(&self) -> Option<Namespace>
Returns the namespace (if any).
Sourcepub fn get_content(&self) -> Option<String>
pub fn get_content(&self) -> Option<String>
Returns the text content of the node.
Sourcepub fn get_attribute(&self, name: &str) -> Option<String>
pub fn get_attribute(&self, name: &str) -> Option<String>
Returns an attribute value by name.
Sourcepub fn get_attribute_ns(&self, name: &str, ns_uri: &str) -> Option<String>
pub fn get_attribute_ns(&self, name: &str, ns_uri: &str) -> Option<String>
Returns an attribute value by name and namespace.
Sourcepub fn get_attributes(&self) -> IndexMap<String, String>
pub fn get_attributes(&self) -> IndexMap<String, String>
Returns all attributes as a map.
Sourcepub fn get_namespace_declarations(&self) -> Vec<Namespace>
pub fn get_namespace_declarations(&self) -> Vec<Namespace>
Returns namespace declarations on this element.
Sourcepub fn get_parent(&self) -> Option<XmlNode>
pub fn get_parent(&self) -> Option<XmlNode>
Returns the parent node (if any).
Sourcepub fn get_child_nodes(&self) -> Vec<XmlNode>
pub fn get_child_nodes(&self) -> Vec<XmlNode>
Returns all child nodes.
Sourcepub fn get_child_elements(&self) -> Vec<XmlNode>
pub fn get_child_elements(&self) -> Vec<XmlNode>
Returns child element nodes (excluding text, comments, etc.).
Sourcepub fn first_child(&self) -> Option<XmlNode>
pub fn first_child(&self) -> Option<XmlNode>
Returns the first child element (if any).
Sourcepub fn last_child(&self) -> Option<XmlNode>
pub fn last_child(&self) -> Option<XmlNode>
Returns the last child element (if any).
Sourcepub fn set_attribute(&self, name: &str, value: &str)
pub fn set_attribute(&self, name: &str, value: &str)
Sets an attribute value.
Sourcepub fn remove_attribute(&self, name: &str) -> Option<String>
pub fn remove_attribute(&self, name: &str) -> Option<String>
Removes an attribute by name.
Returns the previous value if the attribute existed.
Sourcepub fn set_content(&self, content: &str)
pub fn set_content(&self, content: &str)
Sets the text content of this node.
For element nodes, this replaces all children with a single text node. For text/cdata/comment nodes, this sets the content directly.
Sourcepub fn set_prefix(&self, prefix: Option<&str>)
pub fn set_prefix(&self, prefix: Option<&str>)
Sets the namespace prefix of this element.
Sourcepub fn set_namespace_uri(&self, uri: Option<&str>)
pub fn set_namespace_uri(&self, uri: Option<&str>)
Sets the namespace URI of this element.
Sourcepub fn add_namespace_decl(&self, prefix: &str, uri: &str)
pub fn add_namespace_decl(&self, prefix: &str, uri: &str)
Adds a namespace declaration to this element.
Sourcepub fn clear_children(&self)
pub fn clear_children(&self)
Removes all children from this node.
Sourcepub fn is_element(&self) -> bool
pub fn is_element(&self) -> bool
Returns true if this is an element node.
Trait Implementations§
impl Eq for XmlNode
Auto Trait Implementations§
impl Freeze for XmlNode
impl !RefUnwindSafe for XmlNode
impl Send for XmlNode
impl Sync for XmlNode
impl Unpin for XmlNode
impl UnsafeUnpin for XmlNode
impl !UnwindSafe for XmlNode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.