Skip to content

Instantly share code, notes, and snippets.

@pallat
Created February 17, 2016 05:08
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 pallat/7f1f3a9eb1f9d9a43888 to your computer and use it in GitHub Desktop.
Save pallat/7f1f3a9eb1f9d9a43888 to your computer and use it in GitHub Desktop.
xml tag attr chardata
package main
import (
"encoding/xml"
"fmt"
"log"
)
type Password struct {
Type string `xml:"Type,attr"`
Data string `xml:",chardata"`
}
func main() {
password := Password{
Type: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText",
Data: "1234IloveU",
}
b, err := xml.Marshal(&password)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment