title: Unmarshal a specific XML file from zip without extracting
body: <p>I have a zip file having several xml files in it using <a href="https://golang.org/pkg/archive/zip/" rel="nofollow noreferrer">zip</a> and <a href="https://golang.org/pkg/encoding/xml/" rel="nofollow noreferrer">encoding/xml</a> packages from Go archive. The thing I want to do is unmarshalling <strong>only</strong> <code>a.xml</code> into a type -i.e. without looping over all files inside:</p>
  
  <pre><code>test.zip
  ├ a.xml
  ├ b.xml
  └ ...
  </code></pre>
  
  <p><code>a.xml</code> would have a structure like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;app&gt;
          &lt;code&gt;0001&lt;/code&gt;
          &lt;name&gt;Some Test App&lt;/name&gt;
      &lt;/app&gt;
      &lt;app&gt;
          &lt;code&gt;0002&lt;/code&gt;
          &lt;name&gt;Another Test App&lt;/name&gt;
      &lt;/app&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>How to for select and unmarshal the file whose name is provided as a parameter in the commented out lines, for instance:</p>
  
  <pre><code>package marshalutils
  
  import (
      "archive/zip"
      "log"
      "fmt"
      "encoding/xml"
  )
  
  type ApplicationRoot struct {
      XMLName xml.Name `xml:"root"`
      Applications []Application `xml:"app"`
  }
  
  type Application struct {
      Code string `xml:"code"`
      Name string `xml:"name"`
  }
  
  func UnmarshalApps(zipPath string, fileName string) {
      // Open a zip archive for reading.
      reader, err := zip.OpenReader(zipFilePath)
      if err != nil {
          log.Fatal(`ERROR:`, err)
      }
  
      defer reader.Close()
  
      /* 
       * U N M A R S H A L   T H E   G I V E N   F I L E ...
       * ... I N T O   T H E   T Y P E S   A B O V E
       */
  }
  </code></pre>