Golang encoding/xml.Marshaler type example
package encoding/xml
Marshaler is the interface implemented by objects that can marshal themselves into valid XML elements.
MarshalXML encodes the receiver as zero or more XML elements. By convention, arrays or slices are typically encoded as a sequence of elements, one per entry. Using start as the element tag is not required, but doing so will enable Unmarshal to match the XML elements to the correct struct field. One common implementation strategy is to construct a separate value with a layout corresponding to the desired XML and then to encode it using e.EncodeElement. Another common strategy is to use repeated calls to e.EncodeToken to generate the XML output one token at a time. The sequence of encoded tokens must make up zero or more valid XML elements.
Golang encoding/xml.Marshaler type usage example
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
Reference :
Advertisement
Something interesting
Tutorials
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+14.3k Golang : Get uploaded file name or access uploaded files
+6.5k Golang : Combine slices of complex numbers and operation example
+5.6k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)
+15.9k Golang : Read a file line by line
+8.3k Useful methods to access blocked websites
+6.5k Unix/Linux : How to get own IP address ?
+20k Golang : How to run your code only once with sync.Once object
+12.1k Golang : Sort and reverse sort a slice of runes
+5.8k Golang : List all packages and search for certain package
+8.1k Golang : Tell color name with OpenCV example