diff options
author | Valentin Popov <info@valentineus.link> | 2019-01-26 18:37:16 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2019-01-26 18:37:16 +0300 |
commit | fb9c636fcb5274cce6682d476bb2269e03f546ba (patch) | |
tree | e2f2fae06d2ceede7c1487fd7459f3bceb38f29d /src | |
parent | 381a0a03a8ad45bcac875d965fa6fcaa66c831ef (diff) | |
download | bbb2json-fb9c636fcb5274cce6682d476bb2269e03f546ba.tar.xz bbb2json-fb9c636fcb5274cce6682d476bb2269e03f546ba.zip |
Sat, 26 Jan 2019 19:37:16 +0400
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'src')
-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); } |