I have html document
<value>1,2,3</value>
<value>,1,3,5</value>
and what to extract text with code below but it only prints 'value' tags (css selectors). How to print the text from between tags instead using golang html package ?
z := html.NewTokenizer(b)
for {
tt := z.Next()
switch {
case tt == html.ErrorToken:
return
case tt == html.StartTagToken:
t := z.Token()
isAnchor := t.Data == "value"
if isAnchor {
fmt.Println(t.Data)
}
}
}
Text()method that you're looking for ? godoc.org/golang.org/x/net/html#Tokenizer.Text