Struct quick_xml::Element [] [src]

pub struct Element { /* fields omitted */ }

General content of an event (aka node)

Element is a wrapper over the bytes representing the node:

E.g. given a node <name att1="a", att2="b">, the corresponding Event will be

Event::Start(Element {
    buf:    b"name att1=\"a\", att2=\"b\"",
    start:  0,
    end:    b"name att1=\"a\", att2=\"b\"".len(),
    name_end: b"name".len()
})

For performance reasons, most of the time, no character searches but b'<' and b'>' are performed:

  • no attribute parsing: use lazy Attributes iterator only when needed
  • no namespace awareness as it requires parsing all Start element attributes
  • no utf8 conversion: prefer searching statically binary comparisons then use the as_str or into_string methods

Methods

impl Element
[src]

Creates a new Element from the given name. name is a reference that can be converted to a byte slice, such as &[u8] or &str

Consumes self and adds attributes to this element from an iterator over (key, value) tuples. Key and value can be anything that implements the AsRef<[u8]> trait, like byte slices and strings.

name as &u8

whole content as &u8

gets escaped content

Searches for '&' into content and try to escape the coded character if possible returns Malformed error with index within element if '&' is not followed by ';'

gets attributes iterator

gets attributes iterator whose attribute values are unescaped ('&...;' replaced by their corresponding character)

extend the attributes of this element from an iterator over (key, value) tuples. Key and value can be anything that implements the AsRef<[u8]> trait, like byte slices and strings.

consumes entire self (including eventual attributes!) and returns String

useful when we need to get Text event value (which don't have attributes)

consumes entire self (including eventual attributes!) and returns String

useful when we need to get Text event value (which don't have attributes) and unescape XML entities

Adds an attribute to this element from the given key and value. Key and value can be anything that implements the AsRef<[u8]> trait, like byte slices and strings.

Trait Implementations

impl Clone for Element
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Element
[src]

Formats the value using the given formatter.