[−][src]Struct xml::Element
A struct representing an XML element
Fields
name: String
The element's name
ns: Option<String>
The element's namespace
attributes: HashMap<(String, Option<String>), String>
The element's attributes
children: Vec<Xml>
The element's child Xml
nodes
Methods
impl Element
[src]
pub fn new<A>(name: String, ns: Option<String>, attrs: A) -> Element where
A: IntoIterator<Item = (String, Option<String>, String)>,
[src]
A: IntoIterator<Item = (String, Option<String>, String)>,
Create a new Element
, with specified name and namespace.
Attributes are specified as a Vec
of (name, namespace, value)
tuples.
pub fn content_str(&self) -> String
[src]
Returns the character and CDATA contained in the element.
pub fn get_attribute<'a>(
&'a self,
name: &str,
ns: Option<&str>
) -> Option<&'a str>
[src]
&'a self,
name: &str,
ns: Option<&str>
) -> Option<&'a str>
Gets an attribute with the specified name and namespace. When an attribute with the
specified name does not exist None
is returned.
pub fn set_attribute(
&mut self,
name: String,
ns: Option<String>,
value: String
) -> Option<String>
[src]
&mut self,
name: String,
ns: Option<String>,
value: String
) -> Option<String>
Sets the attribute with the specified name and namespace. Returns the original value.
pub fn remove_attribute(
&mut self,
name: &str,
ns: Option<&str>
) -> Option<String>
[src]
&mut self,
name: &str,
ns: Option<&str>
) -> Option<String>
Remove the attribute with the specified name and namespace. Returns the original value.
pub fn get_child<'a>(
&'a self,
name: &str,
ns: Option<&str>
) -> Option<&'a Element>
[src]
&'a self,
name: &str,
ns: Option<&str>
) -> Option<&'a Element>
Gets the first child Element
with the specified name and namespace. When no child
with the specified name exists None
is returned.
ⓘImportant traits for ChildElements<'a, 'b>pub fn get_children<'a, 'b>(
&'a self,
name: &'b str,
ns: Option<&'b str>
) -> ChildElements<'a, 'b>
[src]
&'a self,
name: &'b str,
ns: Option<&'b str>
) -> ChildElements<'a, 'b>
Get all children Element
with the specified name and namespace. When no child
with the specified name exists an empty vetor is returned.
pub fn tag(&mut self, child: Element) -> &mut Element
[src]
Appends a child element. Returns a reference to the added element.
pub fn tag_stay(&mut self, child: Element) -> &mut Element
[src]
Appends a child element. Returns a mutable reference to self.
pub fn text(&mut self, text: String) -> &mut Element
[src]
Appends characters. Returns a mutable reference to self.
pub fn cdata(&mut self, text: String) -> &mut Element
[src]
Appends CDATA. Returns a mutable reference to self.
pub fn comment(&mut self, text: String) -> &mut Element
[src]
Appends a comment. Returns a mutable reference to self.
pub fn pi(&mut self, text: String) -> &mut Element
[src]
Appends processing information. Returns a mutable reference to self.
Trait Implementations
impl Clone for Element
[src]
impl Debug for Element
[src]
impl Display for Element
[src]
impl FromStr for Element
[src]
type Err = BuilderError
The associated error which can be returned from parsing.
fn from_str(data: &str) -> Result<Element, BuilderError>
[src]
impl PartialEq<Element> 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,