title: Parsing XML attributes with GO
body: <p>I am pretty new to GO and I am having trouble extracting attribute values from XML documents. The code below produces the following output:</p>
  
  <p>application ID:: ""
  application name:: ""</p>
  
  <p>My assumption is that I am missing something when it comes to how to use tagging and I would really appreciate it if someone could point me in the right direction. </p>
  
  <pre><code>data:=`&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;applist&gt;
          &lt;app app_id="1234" app_name="abc"/&gt;
      &lt;app app_id="5678" app_name="def"/&gt;
      &lt;/applist&gt; `
  
  type App struct {
      app_id   string  `xml:"app_id,attr"`
      app_name string  `xml:"app_name"`
  }
  
  type AppList struct {
      XMLName xml.Name `xml:"applist"`
      Apps  []App      `xml:"app"`
  }
  
  var portfolio AppList
  err := xml.Unmarshal([]byte(data), &amp;portfolio)
  if err != nil {
      fmt.Printf("error: %v", err)
      return
  }
  fmt.Printf("application ID:: %q\n", portfolio.Apps[0].app_id)
  fmt.Printf("application name:: %q\n", portfolio.Apps[0].app_name)
  </code></pre>