Skip to content

Minimal XML processor for Go that does not to fuck with your markup.

License

Notifications You must be signed in to change notification settings

roblillack/gockl

Repository files navigation

gockl Build Status GoDoc Coverage Status Go Report Card

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:

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: golang/go#9204
  • To not run into broken namespace handling: golang/go#9519
  • To not run into errors when parsing DOCTYPEs with subsets: golang/go#10158

License

MIT/X11.

About

Minimal XML processor for Go that does not to fuck with your markup.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages