Struct exile::Element [−][src]
pub struct Element { /* fields omitted */ }
Expand description
Represents an Element in an XML Document.
Implementations
impl Element
[src]
impl Element
[src]pub fn children(&self) -> impl Iterator<Item = &Element>
[src]
pub fn children(&self) -> impl Iterator<Item = &Element>
[src]Returns the ‘child’ elements of the current element. Consider the XML document:
<r>
<a/>
<b/>
</r>
r’s children()
function would return an iterator over ‘a’ and ‘b’.
Text nodes, processing instructions and comments are skipped/ignored by the iterator.
pub fn children_mut(&mut self) -> impl Iterator<Item = &mut Element>
[src]
pub fn children_mut(&mut self) -> impl Iterator<Item = &mut Element>
[src]Returns the ‘child’ elements of the current element. Consider the XML document:
<r>
<a/>
<b/>
</r>
r’s children_mut()
function would return an iterator over ‘a’ and ‘b’.
Text nodes, processing instructions and comments are skipped/ignored by the iterator.
pub fn child<S: AsRef<str>>(&self, name: S) -> Option<&Element>
[src]
pub fn child<S: AsRef<str>>(&self, name: S) -> Option<&Element>
[src]Find the first occurrance specific child element (does not recurse to lower levels of children).
pub fn add_cdata<S: Into<String>>(&mut self, cdata: S) -> Result<(), XDocErr>
[src]
pub fn add_cdata<S: Into<String>>(&mut self, cdata: S) -> Result<(), XDocErr>
[src]Add a CDATA
node. Will error if the string contains ]]>
as this cannot be represented in
a CDATA
node.
pub fn nodes_len(&self) -> usize
[src]
pub fn nodes_len(&self) -> usize
[src]Get the number of nodes (of any kind) that are children of this node.
pub fn first_node(&self) -> Option<&Node>
[src]
pub fn first_node(&self) -> Option<&Node>
[src]Get the first child node (of any kind)
pub fn fullname(&self) -> &str
[src]
pub fn fullname(&self) -> &str
[src]The fullname of the element (including both the namespace alias prefix and the name). For
example, if the name of this element is ns:foo
, this function returns "ns:foo"
.
Element::name
and [Element:prefix
] give the parsed sections of the fullname.
pub fn name(&self) -> &str
[src]
pub fn name(&self) -> &str
[src]The name of the element without its prefix. For example, if the name of this element is
ns:foo
, name()
will return foo
.
pub fn prefix(&self) -> Option<&str>
[src]
pub fn prefix(&self) -> Option<&str>
[src]The name of the element’s namespace alias prefix. For example, if the name of this element
is ns:foo
, prefix()
will return Some("ns")
.
pub fn set_name<S: AsRef<str>>(&mut self, name: S)
[src]
pub fn set_name<S: AsRef<str>>(&mut self, name: S)
[src]Sets the name of this element without changing the namespace alias prefix. For example, if
the name of this element is ns:foo
then set_name("bar")
will change the fullname to
ns:bar
.
pub fn set_prefix<S: AsRef<str>>(&mut self, prefix: S) -> Result<(), XDocErr>
[src]
pub fn set_prefix<S: AsRef<str>>(&mut self, prefix: S) -> Result<(), XDocErr>
[src]Sets the namespace alias prefix of this element without changing the name. For example, if
the name of this element is ns:foo
then set_prefix("xyz:) will change the fullname to
xyz:foo`.
pub fn set_fullname<S: Into<String>>(
&mut self,
fullname: S
) -> Result<(), XDocErr>
[src]
pub fn set_fullname<S: Into<String>>(
&mut self,
fullname: S
) -> Result<(), XDocErr>
[src]Sets the fullname of the element. For example, if the name of this element is ns:foo
, then
set_fullname("xyz:baz")
will set the fullname to xyz:baz
. set_fullname("baz")
will
eliminate any existing namespace alias prefix and set the fullname to baz
.
pub fn add_attribute<K, V>(&mut self, key: K, value: V) -> Option<String> where
K: AsRef<str>,
V: AsRef<str>,
[src]
pub fn add_attribute<K, V>(&mut self, key: K, value: V) -> Option<String> where
K: AsRef<str>,
V: AsRef<str>,
[src]Inserts a key-value pair into the attributes map.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old value is returned.
pub fn attribute<S: AsRef<str>>(&self, key: S) -> Option<&String>
[src]
pub fn attribute<S: AsRef<str>>(&self, key: S) -> Option<&String>
[src]Gets the attribute value at key
. None
if an attribute by that name does not exist.
pub fn attributes_len(&self) -> usize
[src]
pub fn attributes_len(&self) -> usize
[src]Gets the count of attributes.
pub fn attributes(&self) -> impl Iterator<Item = (&String, &String)> + '_
[src]
pub fn attributes(&self) -> impl Iterator<Item = (&String, &String)> + '_
[src]Gets an iterator over the attribute key/value pairs.
pub fn attribute_keys(&self) -> impl Iterator<Item = &String> + '_
[src]
pub fn attribute_keys(&self) -> impl Iterator<Item = &String> + '_
[src]Gets an iterator over the attribute keys
pub fn add_new_child(&mut self) -> Result<&mut Element, XDocErr>
[src]
pub fn add_new_child(&mut self) -> Result<&mut Element, XDocErr>
[src]Creates a new element as the last child of this element and returns a mut ref to it.
pub fn add_comment<S: Into<String>>(
&mut self,
comment: S
) -> Result<(), XDocErr>
[src]
pub fn add_comment<S: Into<String>>(
&mut self,
comment: S
) -> Result<(), XDocErr>
[src]Append a processing instruction to this element’s nodes.
pub fn has_children(&self) -> bool
[src]
pub fn has_children(&self) -> bool
[src]Does this element have any sub elements. For example, if the element is empty or contains only text and/or pis and/or comments, then false. if the element has elements, then true.
pub fn is_text(&self) -> bool
[src]
pub fn is_text(&self) -> bool
[src]Returns true if there is exactly one sub node, and that sub node is either text or cdata.
Trait Implementations
impl Ord for Element
[src]
impl Ord for Element
[src]impl PartialOrd<Element> for Element
[src]
impl PartialOrd<Element> for Element
[src]fn partial_cmp(&self, other: &Element) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Element) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Element
[src]
impl StructuralEq for Element
[src]
impl StructuralPartialEq for Element
[src]
Auto Trait Implementations
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more