-
-
Save orisano/4287f4784bfea2248de181d46d3d0465 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use quick_xml::events::Event; | |
use quick_xml::reader::Reader; | |
fn main() { | |
let mut reader = Reader::from_file("out.xml").unwrap(); | |
let mut buf = Vec::new(); | |
let mut in_location = false; | |
let mut count = 0; | |
loop { | |
match reader.read_event_into(&mut buf) { | |
Err(e) => panic!("Error: {}", e), | |
Ok(Event::Eof) => break, | |
Ok(Event::Start(ref e)) => { | |
match e.name().as_ref() { | |
b"location" => in_location = true, | |
_ => in_location = false, | |
} | |
} | |
Ok(Event::Text(e)) => { | |
if in_location { | |
if e.windows(6).find(|w| w == b"Africa").is_some() { | |
count += 1; | |
} | |
} | |
} | |
_ => (), | |
} | |
} | |
buf.clear(); | |
println!("Counter = {}", count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment