title: Correct use of XML annotations, fields and structs in custom UnmarshalXML function
body: <p>Consider the following struct:</p>
  
  <pre><code>type MyStruct struct {
      Name string
      Meta map[string]interface{}
  }
  </code></pre>
  
  <p>Which has the following UnmarshalXML function:</p>
  
  <pre><code>func (m *MyStruct) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
      var v struct {
          XMLName xml.Name //`xml:"myStruct"`
          Name    string   `xml:"name"`
          Meta    struct {
              Inner []byte `xml:",innerxml"`
          } `xml:"meta"`
      }
  
      err := d.DecodeElement(&amp;v, &amp;start)
      if err != nil {
          return err
      }
  
      m.Name = v.Name
      myMap := make(map[string]interface{})
  
      // ... do the mxj magic here ... -
  
      temp := v.Meta.Inner
  
      prefix := "&lt;meta&gt;"
      postfix := "&lt;/meta&gt;"
      str := prefix + string(temp) + postfix
      //fmt.Println(str)
      myMxjMap, err := mxj.NewMapXml([]byte(str))
      myMap = myMxjMap
  
      // fill myMap
      //m.Meta = myMap
      m.Meta = myMap["meta"].(map[string]interface{})
      return nil
  }
  </code></pre>
  
  <p>My problem with this code is these lines:</p>
  
  <pre><code>prefix := "&lt;meta&gt;"
  postfix := "&lt;/meta&gt;"
  str := prefix + string(temp) + postfix
  myMxjMap, err := mxj.NewMapXml([]byte(str))
  myMap = myMxjMap
  //m.Meta = myMap
  m.Meta = myMap["meta"].(map[string]interface{})
  </code></pre>
  
  <p>My question is how I make the correct use of the xml annotations (,innerxml etc), fields and structs, so I don't have to manually pre-/append the <code>&lt;meta&gt;&lt;/meta&gt;</code> tags afterwards to get the whole Meta field as a single map.</p>
  
  <p>The full code example is here: <a href="http://play.golang.org/p/Q4_tryubO6">http://play.golang.org/p/Q4_tryubO6</a></p>