docx-rs/docx-core/src/lib.rs

35 lines
925 B
Rust
Raw Normal View History

2019-11-05 08:10:48 +02:00
mod documents;
2019-11-07 09:08:59 +02:00
mod types;
2019-11-05 11:03:23 +02:00
mod xml_builder;
2019-11-05 08:10:48 +02:00
use documents::*;
2019-11-05 11:03:23 +02:00
use xml_builder::*;
2019-11-05 08:10:48 +02:00
2019-09-13 13:41:05 +03:00
use std::fs::File;
use std::io::{self, Write};
2019-11-07 09:08:59 +02:00
use types::*;
2019-09-11 21:28:14 +03:00
2019-09-13 13:41:05 +03:00
use xml::writer::{EmitterConfig, EventWriter, Result, XmlEvent};
pub fn simple() {
2019-11-07 09:08:59 +02:00
let doc = Docx::new();
2019-09-13 13:41:05 +03:00
let mut file = File::create("./dist/output.xml").unwrap();
2019-11-05 08:10:48 +02:00
// let mut b = Vec::new();
// let mut w = EmitterConfig::new()
// .write_document_declaration(false)
// .create_writer(&mut b);
// w.write(
// XmlEvent::start_element("?xml")
// .attr("version", "1.0")
// .attr("encoding", "UTF-8"),
// );
// // w.write("hello world").unwrap();
// w.write(XmlEvent::end_element()).unwrap();
// file.write_all(&b).unwrap();
// file.flush().unwrap();
2019-09-13 13:41:05 +03:00
// assert_eq!(
// str::from_utf8(&b).unwrap(),
// r#"<h:hello xmlns:h="urn:hello-world">hello world</h:hello>"#
// );
2019-09-11 21:28:14 +03:00
}