Skip to content

Instantly share code, notes, and snippets.

@hysios
Created September 20, 2018 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hysios/1a402f7a0e990a58b67679d6d97cc383 to your computer and use it in GitHub Desktop.
Save hysios/1a402f7a0e990a58b67679d6d97cc383 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/xml"
"fmt"
)
type Envelop struct {
XMLName xml.Name
Body Body `xml:"Body"`
}
type Body struct {
XMLName xml.Name
AbilityResponse AbilityResponse `xml:"abilityResponse"`
}
type AbilityResponse struct {
XMLName xml.Name `xml:"abilityResponse"`
Return string `xml:"return"`
}
type Return struct {
MyVal string
}
func main() {
v := Envelop{}
var data = []byte(`
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:abilityResponse xmlns:ns2="http://service.webService.xbsafe.com/">
<return>{"IPAddr":"100.66.21.122","costtime":75,"Register":0,"PlatformID":"0","Online":1,"Result":0}</return>
</ns2:abilityResponse>
</soap:Body>
</soap:Envelope>`)
err := xml.Unmarshal([]byte(data), &v)
if err != nil {
fmt.Printf("error: %v", err)
return
}
fmt.Printf("%#v", v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment