aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2019-01-26 18:37:12 +0300
committerValentin Popov <info@valentineus.link>2019-01-26 18:37:12 +0300
commit381a0a03a8ad45bcac875d965fa6fcaa66c831ef (patch)
tree606dab01265fa5cf385961334965efac9d2322df
parent4b5bbb0f6fa5fe2010b5646b2b6e593a7369f375 (diff)
downloadbbb2json-381a0a03a8ad45bcac875d965fa6fcaa66c831ef.tar.xz
bbb2json-381a0a03a8ad45bcac875d965fa6fcaa66c831ef.zip
Sat, 26 Jan 2019 19:37:12 +0400
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r--src/parser.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs
new file mode 100644
index 0000000..1a8249b
--- /dev/null
+++ b/src/parser.rs
@@ -0,0 +1,51 @@
+extern crate xml;
+
+use std::fs::File;
+use std::io::BufReader;
+use xml::reader::{EventReader, XmlEvent};
+
+pub struct ParserResult {
+ pub external_id: String,
+ pub meeting_id: String,
+ pub meeting_name: String,
+}
+
+pub fn qwerty(content: BufReader<File>) -> ParserResult {
+ let parser = EventReader::new(content);
+
+ let mut data = ParserResult {
+ 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;
+ }
+ _ => {}
+ }
+ }
+
+ return data;
+}