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

#1832 in Web programming

Download history 55/week @ 2024-07-01 19/week @ 2024-07-08 38/week @ 2024-07-15 72/week @ 2024-07-22 96/week @ 2024-07-29 63/week @ 2024-08-05 25/week @ 2024-08-12 49/week @ 2024-08-19 34/week @ 2024-08-26 65/week @ 2024-09-02 7/week @ 2024-09-09 9/week @ 2024-09-16 49/week @ 2024-09-23 30/week @ 2024-09-30 24/week @ 2024-10-07 23/week @ 2024-10-14

127 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

~8MB
~133K SLoC