Expand description
XmlReader — string-typed streaming SAX-style API.
Thin wrapper around XmlBytesReader.
The engine is byte-level (raw Cow<'src, [u8]> events with no UTF-8
cast); this module converts each event’s payload to Cow<'src, str> at
the boundary via from_utf8_unchecked. The bytes are valid UTF-8 by
the Scanner’s construction-time invariant, so the cast is a no-op.
§Why two readers exist
Some callers prefer raw bytes — byte-literal tag matching
(name == b"item"), hash/digest pipelines, format conversion, byte
forwarding — and would rather not pay for the type system’s &str
guarantee. XmlBytesReader serves them. Most callers want validated
strings; XmlReader (this module) serves them and is the recommended
default. The two share a single parser; the only difference is the
payload type each emits.
Structs§
- Attr
- A single attribute from a start tag, with a zero-copy value when possible.
- Attrs
- Lazy iterator over the attributes of a start tag.
- CData
- A
<![CDATA[…]]>section. - Comment
- An XML comment (
<!-- ... -->). The payload is the text strictly between the delimiters. - EndTag
- An end-tag event (
</element>— or the synthetic close emitted after every self-closing<element/>). - Entity
Ref Event::EntityRefpayload — entity name only. String-typed counterpart tocrate::xml_bytes_reader::BytesEntityRef.- Pi
- A processing instruction (
<?target content?>). - Start
Tag - A start-tag event. Source offsets only — no name extraction or attribute parsing happens until you call a method.
- Text
- Character-data text between elements.
- XmlReader
- Streaming XML reader with string-typed events. Thin wrapper around
XmlBytesReader— the engine runs in raw bytes and we re-label each event’s payload asCow<'src, str>at the boundary. The conversion is a no-op: bytes are valid UTF-8 by the Scanner’s construction-time invariant.
Enums§
- Event
- A streaming XML event with lazy access to its payload.
- Event
Into - A streaming XML event with attributes already parsed into a caller-owned buffer.
Functions§
- unescape
- Expand the five XML predefined entity references (
&,<,>,",') and numeric character references (&#NN;,&#xNN;) insides. Intended for callers usingParseOptions::skip_entity_expansionwho want to decode a specific text payload on demand.