Skip to content

Instantly share code, notes, and snippets.

@moorage
Last active January 4, 2016 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moorage/8609958 to your computer and use it in GitHub Desktop.
Save moorage/8609958 to your computer and use it in GitHub Desktop.
import "code.google.com/p/go.net/html"
func innerHtml(n *html.Node) string {
if (n == nil) {
return ""
}
result := ""
if n.Type == html.TextNode {
result = result + strings.TrimSpace(n.Data)
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
if n.Type == html.ElementNode {
childHtml := innerHtml(c)
if len(childHtml) > 0 {
result = result + "<"+n.Data+">" + childHtml + "</"+n.Data+">"
}
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment