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: nibabel.filebasedimages.FileBasedHeader, nibabel.xmlutils.XmlSerializable

Basic wrapper around FileBasedHeader and XmlSerializable.

__init__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

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
stringstr

string 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__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

to_xml(enc='utf-8')

Output should be an xml string with the given encoding. (default: utf-8)