Skip to content

Instantly share code, notes, and snippets.

@pascalopitz
Created May 3, 2014 00:28
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 pascalopitz/11489437 to your computer and use it in GitHub Desktop.
Save pascalopitz/11489437 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/xml"
"fmt"
)
const data = `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns:credentials>
<ns:login>
<ns:username>asdasd</ns:username>
<ns:password>asdasd</ns:password>
</ns:login>
</ns:credentials>
</soapenv:Header>
<soapenv:Body>
<ns:getSessionId>
<ns:username>weqwe</ns:username>
<ns:password>qwe</ns:password>
</ns:getSessionId>
</soapenv:Body>
</soapenv:Envelope>`
type getSessionId struct {
XMLName xml.Name
}
type Body struct {
XMLName xml.Name
getSessionId getSessionId `xml:"getSessionId"`
}
type Envelope struct {
XMLName xml.Name
Body Body `xml:"Body"`
}
func main() {
var envelope Envelope
err := xml.Unmarshal([]byte(data), &envelope)
fmt.Println(envelope, err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment