| Crates.io | rbatis_xml_parser |
| lib.rs | rbatis_xml_parser |
| version | 0.1.0 |
| created_at | 2022-04-21 06:51:10.267691+00 |
| updated_at | 2022-04-21 06:51:10.267691+00 |
| description | Push based streaming parser for xml |
| homepage | https://github.com/Ygg01/rbatis_xml_parser/blob/master/README.md |
| repository | https://github.com/Ygg01/rbatis_xml_parser |
| max_upload_size | |
| id | 571380 |
| size | 363,847 |
Warning: This library is alpha quality, so no guarantees are given.
This crate provides a push based XML parser library that trades well-formedness for error recovery.
rbatis_xml_parser is based largely on html5ever parser, so if you have experience with html5ever you will be familiar with rbatis_xml_parser.
The library is dual licensed under MIT and Apache license.
#Why you should use rbatis_xml_parser
Main use case for this library is when XML is badly formatted, usually from bad XML templates. XML5 tries to handle most common errors, in a manner similar to HTML5.
#Installation
Add rbatis_xml_parser as a dependency in your project manifest.
[dependencies]
rbatis_xml_parser = "0.1.3"
And add crate declaration in your lib.rs
extern crate rbatis_xml_parser
#Getting started
Here is a very simple RcDom backed parser:
let input = "<xml></xml>".to_tendril();
// To parse XML into a tree form, we need a TreeSink
// luckily rbatis_xml_parser comes with a static RC backed tree represetation.
let dom: RcDom = parse(std::iter::once(input), Default::default());
// Do something with dom
The thing that does actual parsing is the parse function. It expects an iterator that can be converted into StrTendril, so you can use std::iter::once(input) or Some(input).into_iter() (where input is StrTendril like structure).