The XML format I need to unmarshal is as follows:
data := ` <table> <name> <code>23764</code> <name>Smith, Jane</name> </name> <name> <code>11111</code> <name>Doe, John</name> </name> </table> ` I have attempted the following structs and code to no avail:
type Customers struct { XMLName xml.Name `xml:"table"` Custs []Customer } type Customer struct { XMLName xml.Name `xml:"name"` Code string `xml:"code"` Name string `xml:"name"` } ... var custs Customers err := xml.Unmarshal([]byte(data), &custs) if err != nil { fmt.Printf("error: %v", err) return } fmt.Printf("%v", custs) for _, cust := range custs.Custs { fmt.Printf("Cust:\n%v\n", cust) } The range prints nothing out, and printing custs only gives me {{ table} []}