15 releases (9 breaking)

new 0.10.0 Sep 14, 2019
0.9.0 Feb 27, 2019
0.8.1 Jan 2, 2019
0.8.0 Dec 13, 2018
0.1.0 Dec 15, 2017

#11 in Parser implementations

Download history 1765/week @ 2019-06-01 1153/week @ 2019-06-08 956/week @ 2019-06-15 1789/week @ 2019-06-22 1471/week @ 2019-06-29 2288/week @ 2019-07-06 2266/week @ 2019-07-13 3002/week @ 2019-07-20 2599/week @ 2019-07-27 1831/week @ 2019-08-03 2759/week @ 2019-08-10 2265/week @ 2019-08-17 4948/week @ 2019-08-24 3115/week @ 2019-08-31 2549/week @ 2019-09-07

10,585 downloads per month
Used in 34 crates (3 directly)

MIT/Apache

66KB
1.5K SLoC

xmlparser

Build Status Crates.io Documentation Rust 1.18+

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 a position of the data in the original document.
  • Good error processing. All error types contain position (line:column) where it occurred.
  • No heap allocations.
  • No dependencies.
  • Tiny. ~1500 LOC and ~40KiB in the release build according to the cargo-bloat.

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