InnerText returns the text between the start and end tags of the object.
(n *html.Node)
| 171 | |
| 172 | // InnerText returns the text between the start and end tags of the object. |
| 173 | func 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. |
| 194 | func SelectAttr(n *html.Node, name string) (val string) { |
searching dependent graphs…