#xml #parser #tokenizer

no-std xmlparser

Pull-based, zero-allocation XML parser

23 releases (12 breaking)

0.13.6 Sep 30, 2023
0.13.5 Oct 18, 2022
0.13.4 Jun 24, 2021
0.13.3 Sep 2, 2020
0.1.0 Dec 15, 2017

#42 in Parser implementations

Download history 265431/week @ 2024-01-29 247289/week @ 2024-02-05 259596/week @ 2024-02-12 246885/week @ 2024-02-19 275078/week @ 2024-02-26 286275/week @ 2024-03-04 276341/week @ 2024-03-11 274380/week @ 2024-03-18 266458/week @ 2024-03-25 281892/week @ 2024-04-01 295053/week @ 2024-04-08 307508/week @ 2024-04-15 311443/week @ 2024-04-22 314736/week @ 2024-04-29 316830/week @ 2024-05-06 329687/week @ 2024-05-13

1,284,169 downloads per month
Used in 1,259 crates (30 directly)


1.5K SLoC


Build Status Crates.io Documentation Rust 1.31+

xmlparser is a low-level, pull-based, zero-allocation XML 1.0 parser.


for token in xmlparser::Tokenizer::from("<tagname name='value'/>") {
    println!("{:?}", token);

Why a new library?

This library is basically a low-level XML tokenizer that preserves the positions of the tokens and is not intended to be used directly. If you are looking for a higher level solution, check out roxmltree.


  • All tokens contain StrSpan structs which represent the position of the substring in the original document.
  • Good error processing. All error types contain the position (line:column) where it occurred.
  • No heap allocations.
  • No dependencies.
  • Tiny. ~1400 LOC and ~30KiB in the release build according to cargo-bloat.
  • Supports no_std builds. To use without the standard library, disable the default features.


  • Currently, only ENTITY objects are parsed from the DOCTYPE. All others are ignored.
  • No tree structure validation. So an XML like <root><child></root></child> or a string without root element will be parsed without errors. You should check for this manually. On the other hand <a/><a/> will lead to an error.
  • Duplicated attributes is not an error. So XML like <item a="v1" a="v2"/> will be parsed without errors. You should check for this manually.
  • UTF-8 only.


  • The library must not panic. Any panic is considered a critical bug and should be reported.
  • The library forbids unsafe code.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps