Skip to main content

Module reader

Module reader 

Source
Expand description

High-level interface for the pull-based XML parser.

The central type is Reader, a low-level, encoding-agnostic, pull-based XML event reader that mirrors the quick-xml 0.41 Reader. It consumes bytes and streams XML Events, borrowing their payload either from the input itself (for the &[u8]/&str sources, giving a zero-copy path) or from a caller-provided Vec<u8> buffer (for arbitrary BufRead sources).

Reading is configured through Config, retrieved with Reader::config() and mutated through Reader::config_mut().

This reader does not manage namespace declarations and is not able to resolve prefixes. For namespace-aware reading, use NsReader, which wraps this Reader and resolves prefixes to namespaces.

§Example

use oxixml_xml::events::Event;
use oxixml_xml::reader::Reader;

let mut reader = Reader::from_str("<tag>text</tag>");
reader.config_mut().trim_text(true);

assert!(matches!(reader.read_event().expect("start"), Event::Start(_)));
assert!(matches!(reader.read_event().expect("text"), Event::Text(_)));
assert!(matches!(reader.read_event().expect("end"), Event::End(_)));
assert!(matches!(reader.read_event().expect("eof"), Event::Eof));

Structs§

BinaryStream
A direct stream to the underlying Readers reader which updates Reader::buffer_position() when read from it.
Config
A parser configuration.
NsReader
A low level encoding-agnostic XML event reader that performs namespace resolution.
Reader
A low level encoding-agnostic XML event reader.

Constants§

DEFAULT_MAX_ELEMENT_DEPTH
Default value of Config::max_element_depth.

Type Aliases§

Span
Range of input in bytes, that corresponds to some piece of XML