17 releases

0.3.3 Mar 18, 2025
0.3.1 Jan 28, 2025
0.3.0 Dec 16, 2024
0.2.3 Mar 12, 2023
0.0.1 Nov 28, 2021

#645 in Web programming

Download history 65/week @ 2024-12-21 119/week @ 2024-12-28 81/week @ 2025-01-04 108/week @ 2025-01-11 20/week @ 2025-01-18 143/week @ 2025-01-25 65/week @ 2025-02-01 27/week @ 2025-02-08 109/week @ 2025-02-15 52/week @ 2025-02-22 54/week @ 2025-03-01 36/week @ 2025-03-08 250/week @ 2025-03-15 99/week @ 2025-03-22 188/week @ 2025-03-29 74/week @ 2025-04-05

619 downloads per month
Used in 7 crates

Apache-2.0 OR MIT

87KB
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

~6MB
~96K SLoC