| Crates.io | mysqldump-quick-xml |
| lib.rs | mysqldump-quick-xml |
| version | 0.1.0 |
| created_at | 2019-03-23 18:39:59.259917+00 |
| updated_at | 2019-03-23 18:39:59.259917+00 |
| description | Convert from mysqldump in xml format to struct using quick-xml. |
| homepage | https://github.com/kilork/mysqldump-quick-xml |
| repository | https://github.com/kilork/mysqldump-quick-xml |
| max_upload_size | |
| id | 123377 |
| size | 7,653 |
Dual-licensed under MIT or the UNLICENSE.
Add dependency to Cargo.toml:
[dependencies]
mysqldump-quick-xml = "0.1"
use mysqldump_quick_xml::MysqlDumpQuickXml;
#[derive(Debug, PartialEq, MysqlDumpQuickXml)]
struct Row {
id: String,
code: String,
}
fn main() {
let xml = r##"
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="db">
<table_data name="table1">
<row>
<field name="id">1</field>
<field name="code">sample 1</field>
</row>
<row>
<field name="id">2</field>
<field name="code">sample 2</field>
</row>
</table_data>
</database>
</mysqldump>
"##;
let rows = Row::from_str(xml);
assert_eq!(
rows,
vec![
Row {
id: "1".into(),
code: "sample 1".into()
},
Row {
id: "2".into(),
code: "sample 2".into()
}
]
)
}