Crates.io | einfach-xml-builder |
lib.rs | einfach-xml-builder |
version | 0.1.0 |
source | src |
created_at | 2023-06-28 14:37:28.407631 |
updated_at | 2023-06-28 14:37:28.407631 |
description | A lightweight and intuitive library for generating XML documents in Rust |
homepage | https://github.com/Deaths-Door/xml-builder-rs |
repository | https://github.com/Deaths-Door/xml-builder-rs/ |
max_upload_size | |
id | 902231 |
size | 26,381 |
A lightweight and intuitive library for generating XML documents in Rust. With an easy-to-use API, it allows you to create well-formed XML structures programmatically. Add elements, attributes, namespaces, and CDATA sections effortlessly.
Add the following line to your Cargo.toml
file:
[dependencies]
xml_builder = "0.1.0"
Here's an example of how to use XML Builder to construct an XML document:
use xml_builder::{Declaration, Element, Attribute, Namespace};
fn main() {
// Create an XML declaration
let declaration = Declaration::new("1.0", "UTF-8").with_standalone(true);
// Create an XML element
let element = Element::new("root")
.add_namespace(Namespace::new("android", "http://example.com"))
.add_attribute(Attribute::new("attr1", "value1"))
.add_attribute(Attribute::new("attr2", "value2"))
.add_child(Element::new("child1"))
.add_child(Element::new("child2"));
// Create a builder with the declaration and element
let builder = Builder::new(declaration, element);
// Print the XML document
println!("{}", builder.to_string());
}
Please note that the examples provided here are simplified and serve as a starting point. For comprehensive documentation of the crate, please visit the crate documentation for a better understanding of the crate's functionalities and APIs.
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.