'Generates the full document as an XML file
Always written as a bytestream in UTF-8 encoding'

def xml(self):

    self.__replaceGenerator()
    xml = StringIO()
    xml.write(_XMLPROLOGUE)
    self.topnode.toXml(0, xml)
    return xml.getvalue()
