Query returns the first node that matches m, from the descendants of n. If none matches, it returns nil.
(n *html.Node, m Matcher)
| 175 | // Query returns the first node that matches m, from the descendants of n. |
| 176 | // If none matches, it returns nil. |
| 177 | func Query(n *html.Node, m Matcher) *html.Node { |
| 178 | for c := n.FirstChild; c != nil; c = c.NextSibling { |
| 179 | if m.Match(c) { |
| 180 | return c |
| 181 | } |
| 182 | if matched := Query(c, m); matched != nil { |
| 183 | return matched |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | // Filter returns the nodes in nodes that match the selector. |
| 191 | func (s Selector) Filter(nodes []*html.Node) (result []*html.Node) { |