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:
encodingstr

string containing xml document

buffer_size: None or int, optional

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

verboseint, optional

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

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

string containing xml document

buffer_size: None or int, optional

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

verboseint, 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:
stringbytes

string (as a bytes object) containing xml document

fnamestr

file name of an xml document.

fptrfile 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:
encstring

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

**kwargsdict

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