Skip to content
This content is for v2.x version. Switch to the Stable version.

xml_rs

Rust · XML DOM parser & serializer · v2.x (Alpha)

Fast, low-memory XML for Rust

xml_rs parses documents into an ID-based DOM tree, lets you navigate and edit them, and serializes back to XML while preserving namespace prefixes and attribute order. It powers XML processing in openxml-office.

This is the v2.x alpha line. It carries the same API as the stable v1.x docs and tracks upcoming work — most notably native XPath support.

Features

Namespace-aware

Full namespace resolution with a prefix → URI stack and correct QName parsing.

Round-trip safe

Serialization preserves original namespace prefixes and attribute order, so parse → serialize stays faithful.

Low memory

An ID-based tree model (arena-like) keeps allocations flat for large documents — with no unsafe code.

Order-preserving attributes

Attributes keep their source order via an index map, important for deterministic output.

Comments & mixed content

Elements, text, mixed content and comments are all preserved in the DOM.

UTF-8 focused

Reads the XML declaration (version, encoding, standalone) and normalizes line breaks.

Next steps