19 releases (12 breaking)

✓ Uses Rust 2018 edition

0.13.1 Mar 12, 2020
0.12.0 Dec 21, 2019
0.11.0 Nov 18, 2019
0.9.0 Feb 27, 2019
0.1.0 Dec 15, 2017

#38 in Parser implementations

Download history 2169/week @ 2019-12-02 2868/week @ 2019-12-09 2836/week @ 2019-12-16 2408/week @ 2019-12-23 2875/week @ 2019-12-30 3645/week @ 2020-01-06 3044/week @ 2020-01-13 3499/week @ 2020-01-20 3479/week @ 2020-01-27 2879/week @ 2020-02-03 2775/week @ 2020-02-10 3176/week @ 2020-02-17 3104/week @ 2020-02-24 2905/week @ 2020-03-02 3023/week @ 2020-03-09 3208/week @ 2020-03-16

12,899 downloads per month
Used in 59 crates (7 directly)

MIT/Apache

64KB
1.5K SLoC

xmlparser

Build Status Crates.io Documentation Rust 1.31+

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

Example

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.

Benefits

  • 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.

Limitations

  • 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.

Safety

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

License

Licensed under either of

at your option.

Contribution

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