If an XML document (and not XML document fragment) is generated, you will need to place an XML declaration in the beginning of the document. Call this method to place an XML declaration in the document. In doing this you will need to place the following text at the beginning of the document: <?xml version="1.0"?>.
If encoding was specified when opening a file or setting a string, you should also place the 'encoding' attribute in the declaration. For example: <?xml version="1.0" encoding="UTF-8"?> XML declarations need to be written before other XML write operations.