Problem parsing html with empty meta tags, <meta/>

I have problems parsing empty meta tags the

For example, this is a common Open Graph meta-tag:

<meta property="og:type" content="article" />

The following code does NOT parse the meta element.

func main() {

	doc := strings.NewReader(`<html><head><meta property="og:type" content="article" /></head></html>`)

	z := html.NewTokenizer(doc)
	for {
		tt := z.Next()
		switch tt {
		case html.StartTagToken:
			t := z.Token()
			fmt.Println(t.Type, t.Data)
		case html.ErrorToken:

Maybe you must add a case for html.SelfClosingTagToken.


Aha… I did not see that token type. Thanks!!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.