Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cascadia
✓ github.com/andybalholm/cascadia
Parses CSS selector and matches first element.
package main
import (
"fmt"
"strings"
"github.com/andybalholm/cascadia"
"golang.org/x/net/html"
)
func main() {
htmlContent := `<html><body><div class="foo">Hello</div></body></html>`
doc, _ := html.Parse(strings.NewReader(htmlContent))
sel, _ := cascadia.Parse(".foo")
node := sel.MatchFirst(doc)
if node != nil {
fmt.Println(node.FirstChild.Data)
}
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.3.4latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.