title: Golang XML processing
body: <p>I am trying to process XML files with complicated structure in Go using the standart encoding/xml package, change values of couple of nodes and save the alternated file. For example:</p>
  
  <pre><code>&lt;description&gt;
      &lt;title-info&gt;
          &lt;genre&gt;Comedy&lt;/genre&gt;
          &lt;author&gt;
              &lt;first-name&gt;Kevin&lt;/first-name&gt;
              &lt;last-name&gt;Smith&lt;/last-name&gt;
          &lt;/author&gt;
          &lt;movie-title&gt;Clerks&lt;/movie-title&gt;
          &lt;annotation&gt;
              &lt;p&gt;!!!&lt;/p&gt;
          &lt;/annotation&gt;
          &lt;keywords&gt;comedy,jay,bob&lt;/keywords&gt;
          &lt;date&gt;&lt;/date&gt;
      &lt;/description&gt;
  &lt;/title-info&gt;
  </code></pre>
  
  <p>And many more fields. I would like to change the node:</p>
  
  <pre><code>&lt;author&gt;
      &lt;first-name&gt;Kevin&lt;/first-name&gt;
      &lt;last-name&gt;Smith&lt;/last-name&gt;
  &lt;/author&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;author&gt;
      &lt;first-name&gt;K.&lt;/first-name&gt;
      &lt;middle-name&gt;Patrick&lt;/middle-name&gt;
      &lt;last-name&gt;Smith&lt;/last-name&gt;
  &lt;/author&gt;
  </code></pre>
  
  <p>However, since files are massive and uses more then 50 tags I really don't want to describe the complete structure to unmarshal them, so I have</p>
  
  <pre><code>type Result struct {
      Title   string   `xml:"description&gt;title-info&gt;movie-title"`
      Authors []Author `xml:"description&gt;title-info&gt;author"`
  }
  
  type Author struct {
      Fname string `xml:"first-name"`
      Mname string `xml:"middle-name"`
      Lname string `xml:"last-name"`
  }
  </code></pre>
  
  <p>for fields I need to work with, but don't know how to keep rest of the file untouched. Looks like I need to use xml.decode to select the nodes I need to change (like at <a href="http://blog.davidsingleton.org/parsing-huge-xml-files-with-go/" rel="nofollow">http://blog.davidsingleton.org/parsing-huge-xml-files-with-go/</a> post) while skipping unneeded tokens to xml.encode, but I can't convert this puzzle to some code. </p>