title: GOlang XML can't create a value and an attribute in one tag using xml.MarshalIndent
body: <p>New to Go and have got to create and xml file using xml.MarshalIndent from the "encoding/xml" package. One requirement is to create a tag like so:</p>
  
  <p>`</p>
  
  <pre><code>   &lt;Attributes&gt;
        &lt;Attribute name="Me"&gt;I really like this GO lang&lt;/Attribute&gt;
        &lt;Attribute name="problem"&gt;the xml package is not behaving&lt;/Attribute&gt;
     &lt;/Attributes&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>An array of tags with a value and an attribute, but no matter what I do (an i have tried lots a different ways), I just can not get it to work.</p>
  
  <p>The code I wrote generates this:
  `</p>
  
  <pre><code>&lt;Attributes&gt;
      &lt;Attribute Name="J3K Solutions"&gt;
          &lt;Attribute&gt;IT Support&lt;/Attribute&gt;
      &lt;/Attribute&gt;
      &lt;Attribute Name="stakoverflow"&gt;
          &lt;Attribute&gt;The place I go for help&lt;/Attribute&gt;
      &lt;/Attribute&gt;
  &lt;/Attributes&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>However I need it to look like this:
  `   </p>
  
  <pre><code>&lt;Attributes&gt;
      &lt;Attribute Name="J3K Solutions" &gt;IT Support&lt;/Attribute&gt;
      &lt;Attribute Name="stakoverflow" &gt;The place I go for help&lt;/Attribute&gt;
  &lt;/Attributes&gt;
  </code></pre>
  
  <p>`
  I've been reading the docs, and trying to get it working for hours now.
  Anyone know if this is doable?</p>
  
  <p>Code:</p>
  
  <pre><code> package main
  
  import (
      "encoding/xml"
      "fmt"
      "time"
  )
  
  type attributes struct {
      Name      string `xml:",attr"`
      Attribute string `xml:"Attribute"`
  }
  
  type fXML struct {
      MessageID string `xml:"MessageID,attr"`
      Timestamp string `xml:"timestamp,attr"`
      Version   string `xml:"version,attr"`
      Header    struct {
          From struct {
              Credential struct {
                  Domain   string `xml:"domain,attr"`
                  Identity string `xml:"Identity"`
              } `xml:"Credential"`
          } `xml:"From"`
          To struct {
              Credential struct {
                  Domain   string `xml:"domain,attr"`
                  Identity string `xml:"Identity"`
              } `xml:"Credential"`
          } `xml:"To"`
          Attributes struct {
              Attribute []attributes
          }
      } `xml:"Header"`
  }
  
  func main() {
  
  rdata := &amp;fXML{}
  t := time.Now()
  rdata.MessageID = "I'm really liken this GO language!"
  rdata.Timestamp = t.Format("2006-01-02T15:04:05")
  rdata.Version = "1.0"
  rdata.Header.From.Credential.Domain = "j3ksolutions.com"
  rdata.Header.From.Credential.Identity = "J3K Solutions"
  rdata.Header.To.Credential.Domain = "stackoverflow.com"
  rdata.Header.To.Credential.Identity = "stackoverflow"
  rdata.Header.Attributes.Attribute = append(rdata.Header.Attributes.Attribute,
      attributes{
          Name:      "J3K Solutions",
          Attribute: "IT Support and Custom Programing",
      })
  rdata.Header.Attributes.Attribute = append(rdata.Header.Attributes.Attribute,
      attributes{
          Name:      "stakoverflow",
          Attribute: "The place I go for help",
      })
  
  if m, err2 := xml.MarshalIndent(rdata, "", "\t"); err2 != nil {
      panic("xml.MarshalIndent FAILED: " + err2.Error())
  } else {
      xmlheader := fmt.Sprintf("&lt;?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?&gt;\n")
      m = append([]byte(xmlheader), m...)
      fmt.Printf("\n%s\n\n", m)
  }
  }
  </code></pre>