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

The element's name

ns

The element's namespace

attributes

The element's attributes

children

The element's child Xml nodes

Methods

impl Element

fn new(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>

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>

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 Display for Element

fn fmt(&self, f: &mut Formatter) -> Result

impl FromStr for Element

type Err = BuilderError

fn from_str(data: &str) -> Result<Element, BuilderError>

Derived Implementations

impl Debug for Element

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl PartialEq for Element

fn eq(&self, __arg_0: &Element) -> bool

fn ne(&self, __arg_0: &Element) -> bool

impl Clone for Element

fn clone(&self) -> Element

fn clone_from(&mut self, source: &Self)