-3
InformationUser:[{

"informationUser.availabiltyStartDate:"09/10/2019 23:56:19",
"informationUSer.avaialblilityEndDate:"28/11/2019 21:19:16",

}]
4

1 回答 1

0

查看文档:https ://golang.org/pkg/encoding/xml/

这里有一个小例子:

package tests

import (
    "encoding/xml"
    "fmt"
    "testing"
)

type Person struct {
    FirstName string `xml:"first_name"`
    LastName string `xml:"last_name"`
    Age int `xml:"age,attr"`

}

func TestXmlToString(t *testing.T) {
    person := Person{
        FirstName: "John",
        LastName:  "Rambo",
        Age:       66,
    }
    data, err := xml.Marshal(person)
    if err != nil {
        t.Fatal(err)
    }
    fmt.Printf("Xml: %s\n", data)
}

func TestStringToXml(t *testing.T) {
    input := `<Person age="66"><first_name>John</first_name><last_name>Rambo</last_name></Person>`
    person := Person{}
    err := xml.Unmarshal([]byte(input), &person)
    if err != nil {
        t.Fatal(err)
    }
    fmt.Printf("Data: %#v\n", person)
}
于 2019-12-02T11:53:09.347 回答