Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razrfalcon/xmlwriter
A simple, streaming XML writer.
https://github.com/razrfalcon/xmlwriter
Last synced: 2 months ago
JSON representation
A simple, streaming XML writer.
- Host: GitHub
- URL: https://github.com/razrfalcon/xmlwriter
- Owner: RazrFalcon
- License: mit
- Created: 2019-07-18T09:30:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-25T08:34:06.000Z (about 1 year ago)
- Last Synced: 2024-10-16T05:59:42.591Z (2 months ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 24
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## xmlwriter
![Build Status](https://github.com/RazrFalcon/xmlwriter/workflows/xmlwriter/badge.svg)
[![Crates.io](https://img.shields.io/crates/v/xmlwriter.svg)](https://crates.io/crates/xmlwriter)
[![Documentation](https://docs.rs/xmlwriter/badge.svg)](https://docs.rs/xmlwriter)
[![Rust 1.32+](https://img.shields.io/badge/rust-1.32+-orange.svg)](https://www.rust-lang.org)
![](https://img.shields.io/badge/unsafe-forbidden-brightgreen.svg)A simple, streaming, partially-validating XML writer that writes XML data to a
std::io::Write implementation.### Features
- A simple, bare-minimum API that panics when writing invalid XML.
- Non-allocating API. All methods are accepting either `fmt::Display` or `fmt::Arguments`.
- Nodes auto-closing.### Example
```rust
use xmlwriter::*;
use std::io;fn main() -> io::Result<()> {
let opt = Options {
use_single_quote: true,
..Options::default()
};let mut w = XmlWriter::new(Vec::::new(), opt);
w.start_element("svg")?;
w.write_attribute("xmlns", "http://www.w3.org/2000/svg")?;
w.write_attribute_fmt("viewBox", format_args!("{} {} {} {}", 0, 0, 128, 128))?;
w.start_element("text")?;
// We can write any object that implements `fmt::Display`.
w.write_attribute("x", &10)?;
w.write_attribute("y", &20)?;
w.write_text_fmt(format_args!("length is {}", 5))?;assert_eq!(std::str::from_utf8(w.end_document()?.as_slice())
.expect("xmlwriter always writes valid UTF-8"),
"
length is 5
"
);
Ok(())
}
```### License
MIT