$Id: 334

Writing struct definitions that match XML file is tedious.

There are tools that can generate that definition based on sample XML file.

A downside of such approach is that if sample XML doesn't have all the fields, they won't be generated.

XML To Go online tool

XML To Go online tool allows to do it in a web browser. Paste XML sample on the left, get Go struct definition on the right.

Zek

Zek is a Go program that reads XML from a file or stdin and prints Go struct definition to stdout.

Chidley

You can use chidley to automatically generate struct definitions from sample XML file.

Install the tool with go get -u github.com/gnewton/chidley.

chidley sample.xml will print Go struct definitions deduced from sample.xml to standard out.

Run chidley to list all cmd-line options.

Options that I find useful:

All options: