Skip to content

Commit

Permalink
fix: xpath to node
Browse files Browse the repository at this point in the history
  • Loading branch information
shiroyk committed Nov 30, 2024
1 parent e3b7325 commit 3ad9d62
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xpath/xpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ func htmlNode(content any) (*html.Node, error) {
case nil:
return &html.Node{Type: html.DocumentNode}, nil
case []*html.Node:
root := &html.Node{Type: html.DocumentNode}
if len(data) == 0 {
return root, nil
return &html.Node{Type: html.DocumentNode}, nil
}
for _, n := range data {
root.AppendChild(n)
root := data[0].Parent
if root == nil {
root = &html.Node{Type: html.DocumentNode}
for _, n := range data {
root.AppendChild(n)
}
}
return root, nil
case *html.Node:
Expand Down

0 comments on commit 3ad9d62

Please sign in to comment.