XMLWriter::startDocument() writes the XML declaration.
Without XMLWriter::startDocument() :
<?php
$xml = new XMLWriter();
$xml->openUri('php://stdout');
$xml->writeElement('message', 'Hello World!');
exit;
/*
Outputs :
<message>Hello World!</message>
*/
?>
With XMLWriter::startDocument() :
<?php
$xml = new XMLWriter();
$xml->openUri('php://stdout');
$xml->startDocument();
$xml->writeElement('message', 'Hello World!');
exit;
/*
Outputs :
<?xml version="1.0"?>
<message>Hello World!</message>
*/
?>