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)
| 62 | // |
| 63 | // Returns an error if the expression `expr` cannot be parsed. |
| 64 | func 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. |
| 73 | func QuerySelector(top *html.Node, selector *xpath.Expr) *html.Node { |
no test coverage detected
searching dependent graphs…