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.
Here is the function that prints the XML code
func processTopic(id string, properties map[string][]string) {
fmt.Printf("<card entity=\"%s\">
", id)
fmt.Println(" <facts>")
for k, v := range properties {
for _,value := range v {
fmt.Printf(" <fact property=\"%s\">%s</fact>
", k, value)
}
}
fmt.Println(" </facts>")
fmt.Println("</card>")
}
How can I get it to write an XML file and then write the code to that XML file?