Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Go - XML - Attributes & its value
package main
import (
type Embed struct {
XMLName xml.Name `xml:"Embed"`
Body string `xml:"Body,omitempty"`
Id XMLId `xml:"Id,omitempty"`
type XMLId struct {
XMLName xml.Name `xml:"Id"`
Value string `xml:",chardata"`
Type string `xml:"type,attr"`
func main() {
fmt.Println("Hello, playground")
em := Embed{}
em.Body = "222"
em.Id.Value = "5"
em.Id.Type = "integer"
x, _ := xml.MarshalIndent(em, "", " ")

This comment has been minimized.

Copy link
Owner Author

@kishorevaishnav kishorevaishnav commented Dec 14, 2014

Also executed the same above code at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment