Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "os"
- "time"
- "regexp"
- "io"
- "bufio"
- )
- func main() {
- file, _ := os.Open("SearchRequest.xml")
- defer file.Close()
- reader := bufio.NewReader(file)
- re, _ := regexp.Compile("<created>(.*)</created>")
- for line, _, e := reader.ReadLine(); e != io.EOF; line, _, e = reader.ReadLine() {
- matches := re.FindStringSubmatch(string(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