Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.49 KB

README.md

File metadata and controls

44 lines (32 loc) · 1.49 KB

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.