MCPcopy Create free account
hub / github.com/antchfx/htmlquery / Query

Function Query

query.go:64–70  ·  view source on GitHub ↗

Query runs the given XPath expression against the given html.Node and returns the first matching html.Node, or nil if no matches are found. Returns an error if the expression `expr` cannot be parsed.

(top *html.Node, expr string)

Source from the content-addressed store, hash-verified

62//
63// Returns an error if the expression `expr` cannot be parsed.
64func Query(top *html.Node, expr string) (*html.Node, error) {
65 exp, err := getQuery(expr)
66 if err != nil {
67 return nil, err
68 }
69 return QuerySelector(top, exp), nil
70}
71
72// QuerySelector returns the first matched html.Node by the specified XPath selector.
73func QuerySelector(top *html.Node, selector *xpath.Expr) *html.Node {

Callers 1

FindOneFunction · 0.85

Calls 2

getQueryFunction · 0.85
QuerySelectorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…