antchfx / htmlquery

htmlquery is golang XPath package for HTML query.
https://github.com/antchfx/xpath
MIT License
739 stars 74 forks source link

text() node function does not work as it should. #20

Closed atakanozceviz closed 4 years ago

atakanozceviz commented 4 years ago

Example:

s := "<span class='output'>24<sup>95</sup></span>"
doc, _ := htmlquery.Parse(strings.NewReader(s))
nx, _ := htmlquery.QueryAll(doc, "//span[@class='output']//text()")
for _, n := range nx {
    fmt.Println(htmlquery.InnerText(n))
}

Output:

2495
24
95
95

Expected Output:

24
95
zhengchun commented 4 years ago

thanks reports, check out at https://github.com/antchfx/xpath/commit/0ca303ad7a5ce2add05eb565b46539857baf0c21