-
-
Save orisano/6f819402698ae0488d08db01763b3e75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "log" | |
| "os" | |
| "strings" | |
| xmlparser "github.com/tamerh/xml-stream-parser" | |
| ) | |
| func main() { | |
| f, err := os.Open(os.Args[1]) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer f.Close() | |
| br := bufio.NewReaderSize(f, 2*1024*1024) | |
| r := xmlparser.NewXMLParser(br, "location") | |
| count := 0 | |
| for xml := range r.Stream() { | |
| if strings.Contains(xml.InnerText, "Africa") { | |
| count++ | |
| } | |
| } | |
| fmt.Println("counter =", count) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment