I am using the "golang.org/x/net/html" package and this example to iterate through an html document.
doc, err := html.Parse(r)
if err != nil {
// ...
}
var f func(*html.Node)
f = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "a" {
// Do something with n...
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
f(c)
}
}
f(doc)
Now I want to get the TokenType of each a
-element.
How do I get the html.TokenType of a html.Node?