[xml] Write the DOCTYPE without using the XML Encoder, and append a newline. Use io.WriteString. Collapse the StartElement a bit (aesthetic).
[tests] Get rid of nilWriter in favour of ioutil.Discard.