xmlschemagenerator

github crates.io docs.rs build status

A collection of helper functions to read a given XML string or stream using quick_xml and generating a Struct (as String) that you can use in your Rust program to serialize or deserialize XML of the same format

You can add this dependency with:

toml [dependencies] xml_schema_generator = "0.1"

Example

```rust use quick_xml::reader::Reader;

use xml_schema_generator::tag::Tag;
use xml_schema_generator::parser::into_struct;

let xml = "<a b=\"c\">d</a>";
let mut reader = Reader::from_str(xml);
let mut root = Tag::new(String::from("root"), Vec::new());

into_struct(&mut reader, &mut root);

let rs_struct = root.to_serde_struct();

```

Contribution

Just create a well tested Pull Request in github

Implemented features

☑ parse UTF-8 xml file

☑ generate Rust struct

☑ detect optional attributes

☑ detect optional children

Ideas (if needed or requested via github)

☐ properly parse namespaces and reflect them in the Rust Struct

☐ detect numeric and boolean fields

☐ improve the implementation of String, &str and [u8]

☐ improve performance

☐ add a main.rs to run this lib independently

☐ generate XSD files

☐ support UTF-16

☐ suppport ISO2022JP

☐ parse multiple XML files into one result

License

Apache-2.0