An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

gockl [![Build Status](https://api.travis-ci.com/roblillack/gockl.svg?branch=master)](https://app.travis-ci.com/github/roblillack/gockl)
[![GoDoc](https://pkg.go.dev/badge/github.com/roblillack/gockl)](https://pkg.go.dev/github.com/roblillack/gockl)
[![Coverage Status](https://coveralls.io/repos/github/roblillack/gockl/badge.svg)](https://coveralls.io/github/roblillack/gockl)
[![Go Report Card](https://goreportcard.com/badge/github.com/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).