xmlm - An XML Marshalling/Unmarshalling package for go

xmlm uses go's struct's tag feature for precise control over how your elements are marshalled.

See xmlm_test.go for an example. Here's an overview:

type MyType struct {
	MyNumber int "my-number" //<my-number> is the tag
	MyArray []int "items|item" //will produce <items><item>1</item><item>2</item>...</items>
	MyOtherArray []float "__parent|float"	//__parent instructs us not to descend, so this 
						//generates (or gets) <float></float> tags at the current level.

To marshal, call:

HumanReadable := true
xml, err := xmlm.Marshal(MyStruct, HumanReadable)

To unmarshal, call:

MyStruct := (*MyType)(nil)
err := Unmarshal(InputXML, &MyStruct, CustomTypes)

where CustomTypes, if not nil, maps tag names to types like this: 

var CustomTypes = map[string]interface{} {
	"custom1": Custom{},
	"custom2": int(0),
	"custom3": (*int)(nil),

CustomTypes is only used by Unmarshal if MyType contains interface values.

If MyType is a root node, you should write a Name() function:

func (o MyType) Name() (string, bool) {return "my-root", true}

If it has attributes, you should write an Attributes() function:

func (o MyType) Attributes() map[string]string {return map[string]string{"xmlns": "example.com/blah"}}

If it should interpret attributes when being unmarshalled, write a SetAttribute member:

func (o *MyType) SetAttribute(name, value string) {xmlm.SetAttr(&o.Attrs, name, value)}

(Note this needs to be on *MyType, not MyType. xmlm.SetAttr() is provided for convienience 
if you keep your attributes in a map). 

If you would like to produce or parse your own value, you may write one or both of the functions:

func (o MyType) Value() (string, bool) {return "MyValue", true}
func (o *MyType) Parse(xml string) bool {
	//return true to stop descent, false to continue it

Known problems:
Unmarshal currently has no way of returning an error...