20 releases (12 breaking)

✓ Uses Rust 2018 edition

0.13.2 Jun 15, 2020
0.13.1 Mar 12, 2020
0.13.0 Jan 7, 2020
0.12.0 Dec 21, 2019
0.1.0 Dec 15, 2017

#52 in Parser implementations

Download history 3512/week @ 2020-03-16 6234/week @ 2020-03-23 4205/week @ 2020-03-30 3969/week @ 2020-04-06 4810/week @ 2020-04-13 4540/week @ 2020-04-20 4579/week @ 2020-04-27 5135/week @ 2020-05-04 7016/week @ 2020-05-11 6821/week @ 2020-05-18 6023/week @ 2020-05-25 4875/week @ 2020-06-01 4985/week @ 2020-06-08 5451/week @ 2020-06-15 4745/week @ 2020-06-22 4340/week @ 2020-06-29

21,960 downloads per month
Used in 93 crates (8 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 a position of the tokens and does not intend to be used directly. If you are looking for a more high-level solution - checkout roxmltree.


  • All tokens contain StrSpan objects which contain position of the substring in the original document.
  • Good error processing. All error types contain position (line:column) where it occurred.
  • No heap allocations.
  • No dependencies.
  • Tiny. ~1400 LOC and ~30KiB in the release build according to the 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. Other 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 an 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 considered as a critical bug and should be reported.
  • The library forbids the 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


  • std