I am looking for a simple (low level) XML Writer in Go, comparable with Java's javax.xml.stream.XMLStreamWriter so I can write code like
writer := ...
writer.StartDocument()
writer.StartElement("p")
writer.CData("Some sample text")
writer.EndElement()
...
Is this supported by a public library or is there a better way to do it in idiomatic Go?
Golang actually has that as a built in package. http://golang.org/pkg/encoding/xml
There is an example here http://golang.org/pkg/encoding/xml/#example_Encoder but it isn't exactly isn't what you are looking for.
I've never used the stream writer you mentioned or any in general so I'm not sure if this fits the bill but I feel like you could easily wrap this to look like the solution you proposed. Let me know if it helps.