Created
September 20, 2018 02:34
-
-
Save hysios/1a402f7a0e990a58b67679d6d97cc383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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