Skip to content

Commit

Permalink
Minor code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengchun committed Oct 5, 2019
1 parent f78b514 commit 1d2a462
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ func CreateXPathNavigator(top *html.Node) *NodeNavigator {
//
// See `QueryAll()` function.
func Find(top *html.Node, expr string) []*html.Node {
exp, err := xpath.Compile(expr)
nodes, err := QueryAll(top, expr)
if err != nil {
panic(err)
}
return QuerySelectorAll(top, exp)
return nodes
}

// FindOne is like Query but will panics if the expression `expr` cannot be parsed.
// See `Query()` function.
func FindOne(top *html.Node, expr string) *html.Node {
exp, err := xpath.Compile(expr)
node, err := Query(top, expr)
if err != nil {
panic(err)
}
return QuerySelector(top, exp)
return node
}

// QueryAll searches the html.Node that matches by the specified XPath expr.
Expand Down

0 comments on commit 1d2a462

Please sign in to comment.