title: Write XML code to XML file in Go
body: <p>I have a script that print-lines XML code, but I need it to write a new XML file and then write the XML code to the file instead of printing it.</p>
  
  <p>Here is the function that prints the XML code</p>
  
  <pre><code>func processTopic(id string, properties map[string][]string) {
      fmt.Printf("&lt;card entity=\"%s\"&gt;\n", id)
      fmt.Println("  &lt;facts&gt;")
      for k, v := range properties {
          for _,value := range v {
              fmt.Printf("    &lt;fact property=\"%s\"&gt;%s&lt;/fact&gt;\n", k, value)
          }
      }
      fmt.Println("  &lt;/facts&gt;")
      fmt.Println("&lt;/card&gt;")
  }
  </code></pre>
  
  <p>How can I get it to write an XML file and then write the code to that XML file?</p>