33 releases (11 breaking)

0.13.2 May 2, 2023
0.13.1 Mar 23, 2023
0.13.0 Feb 23, 2023
0.7.1 Dec 22, 2022

#49 in #dom

Download history 148/week @ 2023-02-14 60/week @ 2023-02-21 3/week @ 2023-02-28 4/week @ 2023-03-07 5/week @ 2023-03-14 24/week @ 2023-03-21 12/week @ 2023-03-28 3/week @ 2023-04-04 11/week @ 2023-04-11 97/week @ 2023-04-18 5/week @ 2023-04-25 71/week @ 2023-05-02 79/week @ 2023-05-09 11/week @ 2023-05-16 6/week @ 2023-05-23 45/week @ 2023-05-30

146 downloads per month
Used in natural-xml-diff

MIT license

3.5K SLoC

Xot - XML Object Tree

Crates.io Documentation

Xot is an XML library for Rust. With Xot you can load XML data into an object tree which you can then manipulate, and serialize back out to XML.

API Documentation


Xot has well-rounded XML support. Supported are namespaces for both elements and attributes. You can also get comments and processing instructions.

Xot exposes the entire XML structure for access and programmatic manipulation.


There are two limitations:

  • DTDs are not supported.

  • Only the UTF-8 encoding is supported.

  • us-ascii is interpreted as UTF-8. This is not strictly correct in that non-ASCII UTF-8 is not rejected.

Why another XML library for Rust?

Use Xot if you need to be able to access XML as a tree, mutate it where necessary, and serialize it back out again. Various Rust XML tree libraries exist but none seem particularly interested in a complete tree manipulation API, so Xot aims to fill that gap.

If you need to access XML as a tree, very high performance, and do not need tree manipulation or serialization at all, I recommend roxmltree.

For extensive features such as Xpath as well as tree manipulation, you can use libxml which wraps the libxml2 C library. Unfortunately its tree access facilities aren't entirely complete, and I've experienced odd errors and even crashes when using it; this was part of the reason I created Xot.

If you need to process big XML data with high performance, you may not want to use a tree library and instead use one of the various XML parser/serialization libraries.

Implementation notes

Xot underneath uses the indextree crate. Xot completely wraps the indextree functionality but the various operations it allows are mostly literally taken from indextree.


~50K SLoC