August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will learn how to modify and customize the generated XML output. The name of the utility, which will be presented in three parts, is modXML.go. Note that the data that is going to be converted into XML is hardcoded in the program for reasons of simplicity.
The first part of modXML.go is as follows:
package main
import (
"encoding/xml"
"fmt"
"os"
)
func main() {
type Address struct {
City, Country string
}
type Employee struct {
XMLName xml.Name `xml:"employee"`
Id int `xml:"id,attr"`
FirstName string `xml:"name>first"`
LastName string `xml:"name>last"`
Initials string `xml:"name>initials"`
Height float32 `xml:"height,omitempty"`
Address
Comment string `xml:",comment"`
}
This is where the structure ...
Read now
Unlock full access