title: Unmarshal Group with Nested XML-RPC in Go
body: <p>I'm using Webfaction API and trying to unmarshal their response to obtain the session ID (12345abcde... below).</p>
  
  <p>How do I access the specific value when its nested under several fields (namely, params>param)?</p>
  
  <p>Code below is at <a href="http://play.golang.org/p/krG4_fXVka" rel="nofollow">http://play.golang.org/p/krG4_fXVka</a></p>
  
  <pre><code>package main
  
  import ("encoding/xml"
          "fmt"
          )
  
  type Result struct {
          XMLName xml.Name `xml:"methodResponse"`
          Values []string `xml:"params&gt;param&gt;value"`
  }
  
  func main() {
  data := `
      &lt;methodResponse&gt;
  &lt;params&gt;
      &lt;param&gt;
          &lt;value&gt;&lt;array&gt;&lt;data&gt;
              &lt;value&gt;&lt;string&gt;12345abcde12345abcde12345&lt;/string&gt;&lt;/value&gt;
              &lt;value&gt;&lt;struct&gt;
                  &lt;member&gt;
                      &lt;name&gt;username&lt;/name&gt;
                      &lt;value&gt;&lt;string&gt;trex&lt;/string&gt;&lt;/value&gt;
                  &lt;/member&gt;
                  &lt;member&gt;
                      &lt;name&gt;home&lt;/name&gt;
                      &lt;value&gt;&lt;string&gt;/home&lt;/string&gt;&lt;/value&gt;
                  &lt;/member&gt;
                  &lt;member&gt;
                      &lt;name&gt;mail_server&lt;/name&gt;
                      &lt;value&gt;&lt;string&gt;Mailbox1&lt;/string&gt;&lt;/value&gt;
                  &lt;/member&gt;
                  &lt;member&gt;
                      &lt;name&gt;web_server&lt;/name&gt;
                      &lt;value&gt;&lt;string&gt;Web12&lt;/string&gt;&lt;/value&gt;
                  &lt;/member&gt;
                  &lt;member&gt;
                      &lt;name&gt;id&lt;/name&gt;
                      &lt;value&gt;&lt;int&gt;1234&lt;/int&gt;&lt;/value&gt;
                  &lt;/member&gt;
              &lt;/struct&gt;&lt;/value&gt;
          &lt;/data&gt;&lt;/array&gt;&lt;/value&gt;
      &lt;/param&gt;
  &lt;/params&gt;
  </code></pre>
  
  <p>`</p>
  
  <pre><code>v := Result{}
  err := xml.Unmarshal([]byte(data), &amp;v)
  if err != nil {
  fmt.Printf("error: %v", err)
          return
  }
  fmt.Printf("XMLName: %#v\n", v.XMLName)
  fmt.Printf("Values: %#v\n", v.Values)
  
  }
  </code></pre>