title: When generating an XML file with Go, how do you create a doctype declaration?
body: <p>Go's <code>xml</code> package is excellent and makes dealing with XML very easy.  There's one thing I'm not sure how to do: when creating an XML document from a native struct, how do you specify the doctype?</p>
  
  <p>For example, these structs:</p>
  
  <pre><code>type Person struct {
      XMLName    xml.Name `xml:"person"`
      FirstName  string   `xml:"firstName"`
      MiddleName string   `xml:"middleName"`
      LastName   string   `xml:"lastName"`
      Age        int64    `xml:"age"`
      Skills     []Skill  `xml:"skills"`
  }
  
  type Skill struct {
      XMLName        xml.Name `xml:"skill"`
      Name           string   `xml:"skillName"`
      YearsPracticed int64    `xml:"practice"`
  }
  </code></pre>
  
  <p>Will generate something like this XML:</p>
  
  <pre><code>&lt;person&gt;
      &lt;firstName&gt;Bob&lt;/firstName&gt;
      &lt;middleName&gt;&lt;/middleName&gt;
      &lt;lastName&gt;Jones&lt;/middleName&gt;
      &lt;age&gt;23&lt;/age&gt;
      &lt;skills&gt;
          &lt;skill&gt;
              &lt;skillName&gt;Cooking&lt;/skillName&gt;
              &lt;practice&gt;3&lt;/practice&gt;
          &lt;/skill&gt;
          &lt;skill&gt;
              &lt;skillName&gt;Basketball&lt;/skillName&gt;
              &lt;practice&gt;4&lt;/practice&gt;
          &lt;/skill&gt;
      &lt;/skills&gt;
  &lt;/person&gt;
  </code></pre>
  
  <p>Which is great, but what do I do to get this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;person&gt;
      &lt;firstName&gt;Bob&lt;/firstName&gt;
      &lt;middleName&gt;&lt;/middleName&gt;
      ...
  </code></pre>
  
  <p>It almost seems <em>too</em> simple, but is this a matter of doing a string append?</p>
  
  <p>And, on the reverse, how would Go's XML parser handle a doctype in a block of text that you wanted to unmarshal into a set of structs?  Ignore it?</p>