Struct xml::Element
[−]
[src]
pub struct Element { pub name: String, pub ns: Option<String>, pub attributes: HashMap<(String, Option<String>), String>, pub children: Vec<Xml>, // some fields omitted }
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]
fn new(
name: String,
ns: Option<String>,
attrs: Vec<(String, Option<String>, String)>
) -> Element
name: String,
ns: Option<String>,
attrs: Vec<(String, Option<String>, String)>
) -> Element
Create a new Element
, with specified name and namespace.
Attributes are specified as a Vec
of (name, namespace, value)
tuples.
fn content_str(&self) -> String
Returns the character and CDATA contained in the element.
fn get_attribute<'a>(&'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.
fn set_attribute(
&mut self,
name: String,
ns: Option<String>,
value: String
) -> Option<String>
&mut self,
name: String,
ns: Option<String>,
value: String
) -> Option<String>
Sets the attribute with the specified name and namespace. Returns the original value.
fn remove_attribute(&mut self, name: &str, ns: Option<&str>) -> Option<String>
Remove the attribute with the specified name and namespace. Returns the original value.
fn get_child<'a>(&'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.
fn get_children<'a, 'b>(
&'a self,
name: &'b str,
ns: Option<&'b str>
) -> ChildElements<'a, 'b>
&'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.
fn tag(&mut self, child: Element) -> &mut Element
Appends a child element. Returns a reference to the added element.
fn tag_stay(&mut self, child: Element) -> &mut Element
Appends a child element. Returns a mutable reference to self.
fn text(&mut self, text: String) -> &mut Element
Appends characters. Returns a mutable reference to self.
fn cdata(&mut self, text: String) -> &mut Element
Appends CDATA. Returns a mutable reference to self.
fn comment(&mut self, text: String) -> &mut Element
Appends a comment. Returns a mutable reference to self.
fn pi(&mut self, text: String) -> &mut Element
Appends processing information. Returns a mutable reference to self.
Trait Implementations
impl Clone for Element
[src]
fn clone(&self) -> Element
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Element
[src]
fn eq(&self, __arg_0: &Element) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Element) -> bool
This method tests for !=
.
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>
Parses a string s
to return a value of this type. Read more