code: def _format_data(self, data, charset):
          
  
          if data is None or data == '':
              return u''
  
          stream = StringIO.StringIO()
          xml = SimplerXMLGenerator(stream, charset)
          xml.startDocument()
          xml.startElement(self._root_element_name(), {})
          self._to_xml(xml, data)
          xml.endElement(self._root_element_name())
          xml.endDocument()
          return stream.getvalue()
docs: Format data into XML.