xml_schema_generator
Library and Binary to convert a given XML input using quick_xml to generate a Struct (as String or file) that you can use in your Rust program to serialize or deserialize XML of the same format
You can add this dependency with:
[]
= "0.6.20"
Example
How to implement the lib
use Reader;
use ;
let xml = "<a b=\"c\">d</a>";
let mut reader = from_str;
if let Ok = into_struct
// you can even parse additional compatible xml files to extend the structure to match those files as well
// see examples/parse_multiple_xml_rs
You find more examples in the /examples directory
Install
from source (env_logger is optional if you do not require additional output)
or download the latest binary at GitHub
How to run the binary
<INPUT_PATH>
)
)
Web Assembly
You can take a look at the result of xml_schema_generator at xml_schema_generator Github Pages
For contribution details take a look into the wasm/README.md
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
☑ add a binary to run this lib independently
☑ replace panic! with Result<>
☑ added serde_xml_rs support
☑ added Option to change the derive attribute
☑ add Options (serde_xml_rs and derive attribute) to binary
☑ parse multiple XML files into one result
☑ attributes and children can be sorted for improved readability
☑ web assembly integration
Ideas (if needed or requested via github)
☐ implement xml:space (default|preserve)
☐ properly parse namespaces and reflect them in the Rust Struct
☐ detect numeric and boolean fields
☐ support enum
☐ improve the implementation of String, &str and [u8]
☐ improve performance
☐ support UTF-16
☐ suppport ISO_2022_JP
License
Apache-2.0