class_docstr: Basic interface for serializing an object to XML
class_docstr_tok: ["Basic","interface","for","serializing","an","object","to","XML"]
docstr: Generate an XML bytestring with a given encoding.
  
  Parameters
  ----------
  enc : :class:`string`
      Encoding to use for the generated bytestring. Default: 'utf-8'
  \*\*kwargs : :class:`dict`
      Additional keyword arguments to :func:`xml.etree.ElementTree.tostring`.
docstr_tok: ["Generate","an","XML","bytestring","with","a","given","encoding",".","Parameters","--","--","--","--","--","enc",":",":","class",":","`","string","`","Encoding","to","use","for","the","generated","bytestring",".","Default",":","'utf-8'","\\","*","\\","*","kwargs",":",":","class",":","`","dict","`","Additional","keyword","arguments","to",":","func",":","`","xml.etree.ElementTree.tostring","`","."]
code: def to_xml(self, enc="utf-8", **kwargs) -> bytes:
      r"""Generate an XML bytestring with a given encoding.
  
      Parameters
      ----------
      enc : :class:`string`
          Encoding to use for the generated bytestring. Default: 'utf-8'
      \*\*kwargs : :class:`dict`
          Additional keyword arguments to :func:`xml.etree.ElementTree.tostring`.
      """
      ele = self._to_xml_element()
      return tostring(ele, enc, **kwargs)
  
file_path: nibabel/nibabel/xmlutils.py
imports: from io import BytesIO
  from xml.etree.ElementTree import Element, SubElement, tostring
  from xml.parsers.expat import ParserCreate
  from .filebasedimages import FileBasedHeader
label_desc: Use image node_id 2 for calling the XmlSerializable obj's underlying member method code with example usage: obj.to_xml(enc) and returns: tostring