Golang encoding/xml

From wikinotes
Revision as of 00:12, 26 June 2022 by Will (talk | contribs)

go's builtin library for parsing xml.
See also: golang encoding, xml

A more detailed introduction to go's encoding interface can be seen in golang encoding/json.

NOTE:

Golang's builtin xml library does not support the full xml spec.
Confirm your needs are supported before using it

Documentation

official docs https://pkg.go.dev/encoding/xml@go1.18.3

Tutorials

tutorialedge https://tutorialedge.net/golang/parsing-xml-with-golang/

Struct Tags

See full details here

type User struct {
    Name  `xml:"Name"`       // <User><Name>value</Name></User>
    Color `xml:"color,attr"` // <User color="value"></User>
    Skip  `xml:"-"`          // <User></User>
}

Known issues: