MCPcopy Create free account
hub / github.com/antchfx/htmlquery / InnerText

Function InnerText

query.go:173–191  ·  view source on GitHub ↗

InnerText returns the text between the start and end tags of the object.

(n *html.Node)

Source from the content-addressed store, hash-verified

171
172// InnerText returns the text between the start and end tags of the object.
173func InnerText(n *html.Node) string {
174 var output func(*strings.Builder, *html.Node)
175 output = func(b *strings.Builder, n *html.Node) {
176 switch n.Type {
177 case html.TextNode:
178 b.WriteString(n.Data)
179 return
180 case html.CommentNode:
181 return
182 }
183 for child := n.FirstChild; child != nil; child = child.NextSibling {
184 output(b, child)
185 }
186 }
187
188 var b strings.Builder
189 output(&b, n)
190 return b.String()
191}
192
193// SelectAttr returns the attribute value with the specified name.
194func SelectAttr(n *html.Node, name string) (val string) {

Callers 4

SelectAttrFunction · 0.85
ValueMethod · 0.85
TestNavigatorFunction · 0.85
TestXPathFunction · 0.85

Calls 1

StringMethod · 0.80

Tested by 2

TestNavigatorFunction · 0.68
TestXPathFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…