Skip to content

Instantly share code, notes, and snippets.

@mattn
Created June 3, 2015 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/d87a9a8ca084054cf2b1 to your computer and use it in GitHub Desktop.
Save mattn/d87a9a8ca084054cf2b1 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"net/http"
"github.com/go-xmlpath/xmlpath"
)
func main() {
res, err := http.Get("http://mattn.kaoriya.net/index.xml")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
root, err := xmlpath.Parse(res.Body)
if err != nil {
log.Fatal(err)
}
p, err := xmlpath.Compile(`//loc`)
if err != nil {
log.Fatal(err)
}
it := p.Iter(root)
for it.Next() {
fmt.Println(it.Node().String())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment