14 releases

0.3.0 Dec 16, 2024
0.2.3 Mar 12, 2023
0.2.2 Feb 18, 2023
0.2.1 Dec 5, 2022
0.0.1 Nov 28, 2021

#365 in Web programming

Download history 45/week @ 2024-09-22 31/week @ 2024-09-29 21/week @ 2024-10-06 28/week @ 2024-10-13 16/week @ 2024-10-20 21/week @ 2024-10-27 20/week @ 2024-11-03 2/week @ 2024-11-10 52/week @ 2024-11-17 78/week @ 2024-11-24 43/week @ 2024-12-01 81/week @ 2024-12-08 212/week @ 2024-12-15 42/week @ 2024-12-22 113/week @ 2024-12-29 63/week @ 2025-01-05

433 downloads per month
Used in 6 crates

Apache-2.0 OR MIT

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

~6.5MB
~118K SLoC