https://github.com/moovweb/gokogiri
A light libxml wrapper for Go
https://github.com/moovweb/gokogiri
Last synced: about 1 year ago
JSON representation
A light libxml wrapper for Go
- Host: GitHub
- URL: https://github.com/moovweb/gokogiri
- Owner: moovweb
- License: mit
- Created: 2011-07-14T11:10:24.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2023-05-27T07:23:05.000Z (about 3 years ago)
- Last Synced: 2025-04-03T20:11:56.706Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 2.31 MB
- Stars: 605
- Watchers: 54
- Forks: 95
- Open Issues: 21
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
Gokogiri
========
LibXML bindings for the Go programming language.
------------------------------------------------
By Zhigang Chen and Hampton Catlin
This is a major rewrite from v0 in the following places:
- Separation of XML and HTML
- Put more burden of memory allocation/deallocation on Go
- Fragment parsing -- no more deep-copy
- Serialization
- Some API adjustment
## Installation
```bash
# Linux
sudo apt-get install libxml2-dev
# Mac
brew install libxml2
go get github.com/moovweb/gokogiri
```
## Running tests
```bash
go test github.com/moovweb/gokogiri/...
```
## Basic example
```go
package main
import (
"net/http"
"io/ioutil"
"github.com/moovweb/gokogiri"
)
func main() {
// fetch and read a web page
resp, _ := http.Get("http://www.google.com")
page, _ := ioutil.ReadAll(resp.Body)
// parse the web page
doc, _ := gokogiri.ParseHtml(page)
// perform operations on the parsed page -- consult the tests for examples
// important -- don't forget to free the resources when you're done!
doc.Free()
}
```