#xml

rxml

Minimalistic, restricted XML 1.0 parser which does not include dangerous XML features

12 releases (breaking)

new 0.9.1 Jan 25, 2023
0.8.2 Dec 17, 2022
0.8.1 May 15, 2022
0.6.0 Mar 25, 2022
0.3.0 Jun 26, 2021

#221 in Parser implementations

Download history 3059/week @ 2022-10-07 2289/week @ 2022-10-14 2767/week @ 2022-10-21 2563/week @ 2022-10-28 3090/week @ 2022-11-04 3820/week @ 2022-11-11 4103/week @ 2022-11-18 3915/week @ 2022-11-25 3394/week @ 2022-12-02 3261/week @ 2022-12-09 2618/week @ 2022-12-16 2265/week @ 2022-12-23 2512/week @ 2022-12-30 3622/week @ 2023-01-06 4237/week @ 2023-01-13 5277/week @ 2023-01-20

16,115 downloads per month
Used in 17 crates (2 directly)

MIT license

375KB
10K SLoC

rxml — Restricted, minimalistic XML 1.0 parser

This crate provides "restricted" parsing of XML 1.0 documents with namespacing.

crate badge docs badge

Warning: This crate is alpha-quality! That means you should probably not yet put it in a network-facing position. CVE numbers may or may not be allocated for security issues in releases where this text is present.

Features (some call them restrictions)

  • No external resources
  • No custom entities
  • No DTD whatsoever
  • No processing instructions
  • No comments
  • UTF-8 input only
  • Namespacing-well-formedness enforced
  • XML 1.0 only
  • Streamed parsing (parser emits a subset of SAX events)
  • Can be driven push- and pull-based
  • Tokio-based asynchronicity supported via the async feature and AsyncParser.

Example

use rxml::EventRead;
let doc = b"<?xml version='1.0'?><hello>World!</hello>";
let mut fp = rxml::FeedParser::new();
fp.feed(doc.to_vec());
fp.feed_eof();
let result = fp.read_all_eof(|ev| {
	println!("got event: {:?}", ev);
});
// true indicates eof
assert_eq!(result.unwrap(), true);
  • rxml_proc offers macros for compile-time conversion of strings to strongly-typed XML-specific str subtypes.

Dependencies

~0.3–4.5MB
~69K SLoC