We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is assuming #61405 is accepted.
Iterating through all the children of an html.Node is tedious. The current code has this example of a recursive function printing out links:
var f func(*html.Node) f = func(n *html.Node) { if n.Type == html.ElementNode && n.Data == "a" { for _, a := range n.Attr { if a.Key == "href" { fmt.Println(a.Val) break } } } for c := n.FirstChild; c != nil; c = c.NextSibling { f(c) } } f(doc)
It would be much nicer with an iterator:
for n := range doc.All() { if n.Type == html.ElementNode && n.Data == "a" { for _, a := range n.Attr { if a.Key == "href" { fmt.Println(a.Val) break } } } }
The text was updated successfully, but these errors were encountered:
CC @neild
Sorry, something went wrong.
No branches or pull requests
This is assuming #61405 is accepted.
Iterating through all the children of an html.Node is tedious. The current code has this example of a recursive function printing out links:
It would be much nicer with an iterator:
The text was updated successfully, but these errors were encountered: