Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io/ioutil"
- "os"
- "time"
- "regexp"
- "strings"
- )
- func main() {
- file, _ := os.Open("SearchRequest.xml")
- defer file.Close()
- data, _ := ioutil.ReadAll(file)
- lines := strings.Split(string(data), "\n")
- re, _ := regexp.Compile("<created>(.*)</created>")
- for _, line := range lines {
- matches := re.FindStringSubmatch(line)
- if len(matches) > 0 {
- date := matches[1]
- t, e := time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", string(date))
- if e != nil {
- fmt.Fprintf(os.Stderr, "Unable to parse %s\n", string(date))
- } else {
- fmt.Printf(t.Format("2006/01/02 15:04:05\n"))
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement