Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razrfalcon/xmlparser
A low-level, pull-based, zero-allocation XML 1.0 parser.
https://github.com/razrfalcon/xmlparser
parser xml
Last synced: 6 days ago
JSON representation
A low-level, pull-based, zero-allocation XML 1.0 parser.
- Host: GitHub
- URL: https://github.com/razrfalcon/xmlparser
- Owner: RazrFalcon
- License: apache-2.0
- Created: 2017-12-02T16:41:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T14:12:26.000Z (2 months ago)
- Last Synced: 2024-12-13T08:03:23.529Z (13 days ago)
- Topics: parser, xml
- Language: Rust
- Homepage:
- Size: 204 KB
- Stars: 130
- Watchers: 7
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# xmlparser
[](https://github.com/RazrFalcon/xmlparser)
[](https://crates.io/crates/xmlparser)
[](https://docs.rs/xmlparser)
[](https://github.com/RazrFalcon/xmlparser/actions?query=branch%3Amaster)*xmlparser* is a low-level, pull-based, zero-allocation
[XML 1.0](https://www.w3.org/TR/xml/) parser.
## Example
```rust
for token in xmlparser::Tokenizer::from("") {
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](https://github.com/RazrFalcon/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
`` or a string without root element will be
parsed without errors. You should check for this manually. On the other
hand `` will lead to an error.
- Duplicated attributes is not an error. So XML like ``
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
- Apache License, Version 2.0 ([LICENSE-APACHE] or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT] or http://opensource.org/licenses/MIT)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.[LICENSE-APACHE]: https://github.com/RazrFalcon/xmlparser/blob/master/LICENSE-APACHE
[LICENSE-MIT]: https://github.com/RazrFalcon/xmlparser/blob/master/LICENSE-MIT