Created
August 13, 2014 05:29
-
-
Save slav123/e0516c272f8f4632766c to your computer and use it in GitHub Desktop.
gokogiri example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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