# xmlWriter: Tools for writing XML data

xmlWriter.py – Simple XML authoring class

class fontTools.misc.xmlWriter.XMLWriter(fileOrPath: str | PathLike[str] | BinaryIO | TextIO, indentwhite: str = ' ', idlefunc: Callable[[], None] | None = None, encoding: str = 'utf_8', newlinestr: str | bytes = '\n')

  Bases: `object`

  close() → None
  write(string, indent=True)

    Writes text.

  writecdata(string)

    Writes text in a CDATA section.

  write8bit(data, strip=False)

    Writes a bytes() sequence into the XML, escaping non-ASCII bytes. When this is read in xmlReader, the original bytes can be recovered by encoding to ‘latin-1’.

  write_noindent(string)

    Writes text without indentation.

  newline()
  comment(data)
  simpletag(_TAG_, *args, **kwargs)
  begintag(_TAG_, *args, **kwargs)
  endtag(_TAG_)
  dumphex(data)
  indent()
  dedent()
  stringifyattrs(*args, **kwargs)

fontTools.misc.xmlWriter.escape(data)

  Escape characters not allowed in XML 1.0.

fontTools.misc.xmlWriter.escapeattr(data)

fontTools.misc.xmlWriter.escape8bit(data)

  Input is Unicode string.

fontTools.misc.xmlWriter.hexStr(s)