You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
856 B
Rust
36 lines
856 B
Rust
use regex::Regex;
|
|
use std::path::Path;
|
|
use std::fs::read_to_string;
|
|
use serde::Deserialize;
|
|
use quick_xml::de::{from_str, DeError};
|
|
|
|
#[derive(Debug, Deserialize, PartialEq)]
|
|
struct Struct {
|
|
Name: String,
|
|
#[serde(rename = "Field", default)]
|
|
fields: Vec<Field>,
|
|
#[serde(rename = "Struct", default)]
|
|
structs: Vec<Struct>
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, PartialEq)]
|
|
struct Field {
|
|
Name: String,
|
|
#[serde(rename = "$value")]
|
|
value:String,
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
// filepath
|
|
let filepath: &Path = Path::new("/home/dad/research/ClinicalTrialsDataProcessing/Parser/simple.xml");
|
|
|
|
// read in a file
|
|
let xml = read_to_string(filepath).unwrap();
|
|
//let xml = r#"<Field Name="NCTId">NCT01874691</Field>"#;
|
|
|
|
let s: Struct = from_str(&xml).unwrap();
|
|
|
|
println!("{:?}", s.Name)
|
|
} |