Uses the character encoding of the XMLSerializer.
Motivation: when XMLSerializer is created, an encoding is specified. This
encoding is used when writing the XML declaration. Using the
serializeDocument(Elem, Writer) can lead to a stupid-user-error where the
encoding given and the encoding of the Writer (e.g. OutputStreamWriter) are not
For example, on a platform, whose default encoding is ISO-8859-1, the following
innocent looking code would lead to a disaster:
XMLSerializer("UTF-8", true).serializeDocument(root, new OutputStreamWriter(myOutputStream))
In the above, the declaration written by XMLSerializer would state "UTF-8", but
the data written by the Writer would be in ISO-8859-1.