Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func main() {
- //..
- // find all <li> elements
- var processAllPokemon func(*html.Node)
- processAllPokemon = func(n *html.Node) {
- if n.Type == html.ElementNode && n.Data == "li" {
- // process the Pokemon details within each <li> element
- processNode(n)
- }
- // traverse the child nodes
- for c := n.FirstChild; c != nil; c = c.NextSibling {
- processAllPokemon(c)
- }
- }
- // make a recursive call to your function
- processAllPokemon(doc)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement