diff options
-rw-r--r-- | src/main.rs | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/src/main.rs b/src/main.rs index 061c7ce..af08eae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,63 +1,11 @@ -#[macro_use] -extern crate serde_derive; -extern crate serde; -extern crate serde_json; -extern crate xml; - use std::fs::File; use std::io::BufReader; -use serde::Serialize; -use serde_json::Result; -use xml::reader::{EventReader, XmlEvent}; - -#[derive(Serialize, Clone)] -struct Record { - external_id: String, - meeting_id: String, - meeting_name: String, -} +mod parser; +use parser::*; fn main() { - let file = File::open("events.xml").unwrap(); - let file = BufReader::new(file); - - let parser = EventReader::new(file); - - let mut data = Record { - external_id: "".to_string(), - meeting_id: "".to_string(), - meeting_name: "".to_string(), - }; - - for element in parser { - match element { - Ok(XmlEvent::StartElement { - name: _, - attributes, - .. - }) => { - for attribute in attributes { - let name: String = attribute.name.local_name.to_string(); - let value: String = attribute.value.to_string(); - - if name == "externalId" { - data.external_id = value; - } else if name == "meetingId" { - data.meeting_id = value; - } else if name == "meetingName" { - data.meeting_name = value; - } - } - } - Err(error) => { - dbg!(error); - break; - } - _ => {} - } - } - - let j = serde_json::to_string(&data); - dbg!(j); + let file: File = File::open("events.xml").unwrap(); + let data: ParserResult = qwerty(BufReader::new(file)); + dbg!(data.meeting_name); } |