code: def safedata(self, data, cdata=True):
          r
          safe = ('<![CDATA[%s]]>' % data) if cdata else cgi.escape(str(data), True)
          return safe
docs: r"""Convert xml special chars to entities.
  
          :param data: the data will be converted safe.
          :param cdata: whether to use cdata. Default：``True``. If not, use :func:`cgi.escape` to convert data.
          :type cdata: bool
          :rtype: str