21 releases (12 breaking)

0.13.3 Sep 2, 2020
0.13.2 Jun 15, 2020
0.13.1 Mar 12, 2020
0.12.0 Dec 21, 2019
0.1.0 Dec 15, 2017

#47 in Parser implementations

Download history 10403/week @ 2021-02-26 10094/week @ 2021-03-05 10162/week @ 2021-03-12 9701/week @ 2021-03-19 10681/week @ 2021-03-26 9688/week @ 2021-04-02 11201/week @ 2021-04-09 8402/week @ 2021-04-16 10240/week @ 2021-04-23 8307/week @ 2021-04-30 10725/week @ 2021-05-07 11998/week @ 2021-05-14 11671/week @ 2021-05-21 11014/week @ 2021-05-28 11232/week @ 2021-06-04 12299/week @ 2021-06-11

42,877 downloads per month
Used in 172 crates (13 directly)

MIT/Apache

66KB
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 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.

Benefits

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

Limitations

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

Safety

  • The library must not panic. Any panic is considered a critical bug and should be reported.
  • The library forbids 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

Features

  • std