Module quick_xml::events

source ·
Expand description

Defines zero-copy XML events used throughout this library.

A XML event often represents part of a XML element. They occur both during reading and writing and are usually used with the stream-oriented API.

For example, the XML element

<name attr="value">Inner text</name>

consists of the three events Start, Text and End. They can also represent other parts in an XML document like the XML declaration. Each Event usually contains further information, like the tag name, the attribute or the inner text.

See Event for a list of all possible events.


When reading a XML stream, the events are emitted by Reader::read_event and Reader::read_event_into. You must listen for the different types of events you are interested in.

See Reader for further information.


When writing the XML document, you must create the XML element by constructing the events it consists of and pass them to the writer sequentially.

See Writer for further information.



  • CDATA content contains unescaped data from the reader. If you want to write them as a text, convert it to BytesText
  • An XML declaration (Event::Decl).
  • A struct to manage Event::End events
  • Opening tag data (Event::Start), with optional attributes.
  • Data from various events (most notably, Event::Text) that stored in XML in escaped form. Internally data is stored in escaped form