[][src]Struct xml::Element

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]

pub fn new<A>(name: String, ns: Option<String>, attrs: A) -> Element where
    A: IntoIterator<Item = (String, Option<String>, String)>, 
[src]

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]

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]

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]

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]

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]

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.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.