# NiBabel

### Access a cacophony of neuro-imaging file formats

# `xmlutils`

Thin layer around xml.etree.ElementTree, to abstract nibabel xml support

`XmlBasedHeader`() | Basic wrapper around FileBasedHeader and XmlSerializable.
`XmlParser`([encoding, buffer_size, verbose]) | Base class for defining how to parse xml-based image snippets.
`XmlSerializable`() | Basic interface for serializing an object to XML

## `XmlBasedHeader`

class nibabel.xmlutils.XmlBasedHeader

  Bases: `FileBasedHeader`, `XmlSerializable`

  Basic wrapper around FileBasedHeader and XmlSerializable.

  __init__(*args, **kwargs)

## `XmlParser`

class nibabel.xmlutils.XmlParser(encoding='utf-8', buffer_size=35000000, verbose=0)

  Bases: `object`

  Base class for defining how to parse xml-based image snippets.

  Image-specific parsers should define:

    StartElementHandler EndElementHandler CharacterDataHandler

  Parameters:
    encoding str

      string containing xml document

    buffer_size: None or int, optional

      size of read buffer. None uses default buffer_size from xml.parsers.expat.

    verbose int, optional

      amount of output during parsing (0=silent, by default).

  __init__(encoding='utf-8', buffer_size=35000000, verbose=0)
    Parameters:
      encoding str

        string containing xml document

      buffer_size: None or int, optional

        size of read buffer. None uses default buffer_size from xml.parsers.expat.

      verbose int, optional

        amount of output during parsing (0=silent, by default).

  CharacterDataHandler(data)
  EndElementHandler(name)
  HANDLER_NAMES = ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler']
  StartElementHandler(name, attrs)
  parse(string=None, fname=None, fptr=None)
    Parameters:
      string bytes

        string (as a bytes object) containing xml document

      fname str

        file name of an xml document.

      fptr file pointer

        open file pointer to an xml documents

## `XmlSerializable`

class nibabel.xmlutils.XmlSerializable

  Bases: `object`

  Basic interface for serializing an object to XML

  __init__(*args, **kwargs)
  to_xml(enc='utf-8', **kwargs) → bytes

    Generate an XML bytestring with a given encoding.

    Parameters:
      enc `string`

        Encoding to use for the generated bytestring. Default: ‘utf-8’

      **kwargs `dict`

        Additional keyword arguments to `xml.etree.ElementTree.tostring()`.