Golang encoding/xml: Difference between revisions

From wikinotes
Line 21: Line 21:
|}
|}
</blockquote><!-- Tutorials -->
</blockquote><!-- Tutorials -->
= Basics =
<blockquote>
To parse xml within go:
* you define <code>MarshallText/UnmarshallText</code> methods on an object
* declare a variable with the types you'd like to use
* <code>xml.Unmarshall(your_type)</code> will use type info to serialize/deserialize objects
</blockquote><!-- Basics -->


= Struct Tags =
= Struct Tags =

Revision as of 23:12, 25 June 2022

go's builtin library for parsing xml.


WARNING:

wip

Documentation

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: