https://github.com/roblillack/gockl
Minimal XML processor for Go that does not to fuck with your markup.
https://github.com/roblillack/gockl
golang golang-library html-parser xml xml-parsing
Last synced: 3 months ago
JSON representation
Minimal XML processor for Go that does not to fuck with your markup.
- Host: GitHub
- URL: https://github.com/roblillack/gockl
- Owner: roblillack
- License: mit
- Created: 2015-04-20T08:10:33.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-11-07T07:36:31.000Z (over 1 year ago)
- Last Synced: 2024-11-07T08:27:27.439Z (over 1 year ago)
- Topics: golang, golang-library, html-parser, xml, xml-parsing
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
gockl [](https://app.travis-ci.com/github/roblillack/gockl)
[](https://pkg.go.dev/github.com/roblillack/gockl)
[](https://coveralls.io/github/roblillack/gockl)
[](https://goreportcard.com/report/github.com/roblillack/gockl)
=======
gockl is a minimal XML processor for Go that does not to fuck with your markup.
Supported & tested Go versions are: 1.2 – 1.23.
#### Usage
Transparently decode XML string `input` and re-encode to string `output` without affecting
the underlying structure of the original file:
```go
buf := bytes.Buffer{}
z := gockl.New(input)
for {
t, err := z.Next()
if err != nil {
break
}
if el, ok := t.(gockl.ElementToken); ok {
log.Println(el.Name())
}
buf.WriteString(t.Raw())
}
output := buf.String()
```
#### Why?
- To ease creating XML document diffs, if only minor changes to a document are done
- To not run into over-escaping of text data in `encoding/xml`: https://github.com/golang/go/issues/9204
- To not run into broken namespace handling: https://github.com/golang/go/issues/9519
- To not run into errors when parsing DOCTYPEs with subsets: https://github.com/golang/go/issues/10158
#### License
[MIT/X11](https://github.com/roblillack/gockl/blob/master/LICENSE.txt).