| Crates.io | xmlem |
| lib.rs | xmlem |
| version | 0.3.3 |
| created_at | 2021-11-19 11:11:53.965298+00 |
| updated_at | 2025-03-18 15:31:14.303711+00 |
| description | XML DOM implementation with pretty printing |
| homepage | |
| repository | https://github.com/xmlem/xmlem |
| max_upload_size | |
| id | 484420 |
| size | 115,362 |
XML DOM manipulation for Rust.
let mut doc = Document::from_str("<root><potato /></root>").unwrap();
let root = doc.root();
let potato = root.query_selector(&doc, Selector::new("potato").unwrap()).unwrap();
potato.append_new_element(&mut doc, (
"wow",
[
("easy", "true"),
("x", "200"),
("a-null", "\0"),
],
));
let decl = Declaration::v1_1();
doc.set_declaration(Some(decl));
doc.set_doctype(Some("not-html"));
println!("{}", doc.to_string_pretty());
/*
Prints:
<?xml version="1.1" encoding="utf-8" ?>
<!DOCTYPE not-html>
<root>
<potato>
<wow easy="true" x="200" a-null="�" />
</potato>
</root>
*/
You can run this example with cargo run --example readme, and see the examples/readme.rs file.
This project is licensed under either of
at your option.