Enum xml::writer::events::XmlEvent [] [src]

pub enum XmlEvent<'a> {
    StartDocument {
        version: XmlVersion,
        encoding: Option<&'a str>,
        standalone: Option<bool>,
    },
    ProcessingInstruction {
        name: &'a str,
        data: Option<&'a str>,
    },
    StartElement {
        name: Name<'a>,
        attributes: Vec<Attribute<'a>>,
        namespace: &'a Namespace,
    },
    EndElement {
        name: Name<'a>,
    },
    CData(&'a str),
    Comment(&'a str),
    Characters(&'a str),
}

An element of an XML output stream.

Items of this enum are consumed by writer::EventWriter. They correspond to different elements of an XML document.

Variants

StartDocument

Corresponds to XML document declaration.

This event should always be written before any other event. If it is not written at all, default XML declaration will be outputted.

Fields

version

XML version.

If XML declaration is not present, defaults to Version10.

encoding

XML document encoding.

standalone

XML standalone declaration.

ProcessingInstruction

Denotes an XML processing instruction.

This event contains a processing instruction target (name) and opaque data. It is up to the application to process them.

Fields

name

Processing instruction target.

data

Processing instruction content.

StartElement

Denotes a beginning of an XML element.

This event is emitted after parsing opening tags or after parsing bodiless tags. In the latter case EndElement event immediately follows.

TODO: ideally names and attributes should be entirely references, including internal strings.

Fields

name

Qualified name of the element.

attributes

A list of attributes associated with the element.

Currently attributes are not checked for duplicates (TODO).

namespace

Contents of the namespace mapping at this point of the document.

EndElement

Denotes an end of an XML document.

This event is emitted after parsing closing tags or after parsing bodiless tags. In the latter case it is emitted immediately after corresponding StartElement event.

Fields

name

Qualified name of the element.

CData

Denotes CDATA content.

This event contains unparsed data. No unescaping will be performed.

It is possible to configure a parser to emit Characters event instead of CData. See reader::ParserConfiguration structure for more information.

Comment

Denotes a comment.

It is possible to configure a parser to ignore comments, so this event will never be emitted. See reader::ParserConfiguration structure for more information.

Characters

Denotes character data outside of tags.

Contents of this event will always be unescaped, so no entities like &lt; or &amp; or &#123; will appear in it.

It is possible to configure a parser to trim leading and trailing whitespace for this event. See reaer::ParserConfiguration structure for more information.