MCPcopy Create free account
hub / github.com/andybalholm/cascadia / Query

Function Query

selector.go:177–188  ·  view source on GitHub ↗

Query returns the first node that matches m, from the descendants of n. If none matches, it returns nil.

(n *html.Node, m Matcher)

Source from the content-addressed store, hash-verified

175// Query returns the first node that matches m, from the descendants of n.
176// If none matches, it returns nil.
177func 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.
191func (s Selector) Filter(nodes []*html.Node) (result []*html.Node) {

Callers 1

TestMatchersFunction · 0.85

Calls 1

MatchMethod · 0.65

Tested by 1

TestMatchersFunction · 0.68