You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use htmlquery.Query(parse, "string(//div[@id='postlist'])")
to extract the text content, but it return nil. It seem it does not support the "string" xpath function?
The text was updated successfully, but these errors were encountered:
Yes, supports string , you can check xpath document.
string is a function that return string value, this means you can not call htmlquery.Query, htmlquery.Query is used for query node-set. you should use Evaluate method, like this:
expr, _:=xpath.Compile("count(//img)")
v:=expr.Evaluate(htmlquery.CreateXPathNavigator(doc)).(float64)
fmt.Printf("total count is %f", v)
another ways is use text() on your xpath query. like this htmlquery.Query(parse, "//div[@id='postlist']/text()")
I want to use
htmlquery.Query(parse, "string(//div[@id='postlist'])")
to extract the text content, but it return nil. It seem it does not support the "string" xpath function?
The text was updated successfully, but these errors were encountered: