title: XML parsing in Go for same tags under different parent tag
body: <p>I am new to Go, and I am trying to parse an XML file.  My goal is to get the values of all the config tags by making only one structure for them. Not a separate structure for each parent tag. Below is the XML file and what I have done.</p>
  
  <p>My XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;TestFramework&gt;
          &lt;config&gt;
              &lt;name&gt;TEST_COMPONENT&lt;/name&gt;
              &lt;value&gt;FILMS&lt;/value&gt;
              &lt;description&gt;
             Name of the test Films.
              &lt;/description&gt;
          &lt;/config&gt;
          &lt;config&gt;
              &lt;name&gt;TESTER_NAME&lt;/name&gt;
              &lt;value&gt;abc@xyz.com&lt;/value&gt;
              &lt;description&gt;
              Name or email of the tester.
              &lt;/description&gt;
          &lt;/config&gt;
      &lt;/TestFramework&gt;
      &lt;Product&gt;
          &lt;config&gt;
              &lt;name&gt;PRODUCT_RELEASE&lt;/name&gt;
              &lt;value&gt;2.1&lt;/value&gt;
              &lt;description&gt;
              Name or email of the tester.
              &lt;/description&gt;
          &lt;/config&gt;
          &lt;config&gt;
              &lt;name&gt;PRODUCT_BUILD&lt;/name&gt;
              &lt;value&gt;7.1.3182018&lt;/value&gt;
              &lt;description&gt;
              Name or email of the tester.
              &lt;/description&gt;
          &lt;/config&gt;
      &lt;/Product&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>My Go program:</p>
  
  <pre><code>package main
  
  import (
      "encoding/xml"
      "fmt"
      "io/ioutil"
      "os"
  )
  
  type ConfigFile struct {
      Configs []Config `xml:"config"`
  }
  
  type Config struct {
      Name  string `xml:"name"`
      Value string `xml:"value"`
  }
  
  func main() {
      xmlFile, err := os.Open("octa_config.xml")
      m := make(map[string]string)
      if err != nil {
          fmt.Println(err)
      }else {
          fmt.Println("Successfully Opened octa_config.xml")
      }
      defer xmlFile.Close()
      byteValue, _ := ioutil.ReadAll(xmlFile)
      var c ConfigFile
      xml.Unmarshal(byteValue,&amp;c)
      for i := 0; i &lt; len(c.Configs); i++ {
          m[c.Configs[i].Name]=c.Configs[i].Value
      }
      for k,v :=range m{
          fmt.Println( k,v)
      }
  }
  </code></pre>
  
  <p>I know I can make a struct like this:</p>
  
  <pre><code>type TestFramework struct {
      Configs []Config `xml:"TestFramework&gt;config"`
  }
  </code></pre>
  
  <p>But I don't want to use this:</p>
  
  <pre><code>`xml:"TestFramework&gt;config"`
  </code></pre>
  
  <p>I am getting output like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>D:\Go&gt;go run config_nim.go
  Successfully Opened octa_config.xml
  
  D:\Go&gt;
  </code></pre>