13 releases

0.2.3 Mar 12, 2023
0.2.2 Feb 18, 2023
0.2.1 Dec 5, 2022
0.2.0 Nov 22, 2022
0.0.1 Nov 28, 2021

#1492 in Web programming

Download history 54/week @ 2023-12-18 43/week @ 2023-12-25 20/week @ 2024-01-01 18/week @ 2024-01-08 24/week @ 2024-01-15 3/week @ 2024-01-22 41/week @ 2024-01-29 33/week @ 2024-02-05 34/week @ 2024-02-12 114/week @ 2024-02-19 59/week @ 2024-02-26 18/week @ 2024-03-04 68/week @ 2024-03-11 19/week @ 2024-03-18 16/week @ 2024-03-25 256/week @ 2024-04-01

361 downloads per month
Used in 5 crates

Apache-2.0 OR MIT

67KB
2K SLoC

xmlem

XML DOM manipulation for Rust.

Quickstart

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="&#x0000;" />
  </potato>
</root>
*/

You can run this example with cargo run --example readme, and see the examples/readme.rs file.

Projects using xmlem

  • kbdgen: a keyboard layout generation tool used by minority and indigenous language communities
  • xml-pretty: a command line XML prettifier

License

This project is licensed under either of

at your option.

Dependencies

~7MB
~121K SLoC