Skip to content

Instantly share code, notes, and snippets.

@slav123
Created August 13, 2014 05:29
Show Gist options
  • Save slav123/e0516c272f8f4632766c to your computer and use it in GitHub Desktop.
Save slav123/e0516c272f8f4632766c to your computer and use it in GitHub Desktop.
gokogiri example
package main
import(
"fmt"
"github.com/moovweb/gokogiri"
)
func main() {
// Parse even this bad bit of HTML and make it valid
html := "<h2>I am so malformatted</h2>"
doc, _ := gokogiri.ParseHtml([]byte(html))
defer doc.Free()
header := doc.Root().FirstChild().FirstChild()
header.SetName("h1")
fmt.Println(doc.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment