package main import ( "encoding/xml" "strings" ) func main() { s := "234.32.12.34:4222" idx := strings.LastIndex(s, ":") ip := s[:idx] port := strings.TrimLeft(s[idx:], ":") println(ip, port) var t HotelOrderValidateRES str := `0[{"date":"2020-08-03","price":165000,"quota":1}]` err := xml.Unmarshal([]byte(str), &t) if nil != err { panic(err) } var bt []byte println(t.InventoryPrice) bt, err = xml.Marshal(t) if nil != err { panic(err) } println(string(bt)) } type BaseOrderRES struct { XMLName xml.Name `xml:"Result"` Message string `xml:"Message"` ResultCode int `xml:"ResultCode"` } type HotelOrderValidateRES struct { *BaseOrderRES CreateOrderValidateKey string `xml:"CreateOrderValidateKey"` InventoryPrice string `xml:"InventoryPrice"` }