class_docstr: Base class for defining how to parse xml-based image snippets.
  
  Image-specific parsers should define:
      StartElementHandler
      EndElementHandler
      CharacterDataHandler
class_docstr_tok: ["Base","class","for","defining","how","to","parse","xml-based","image","snippets",".","Image-specific","parsers","should","define",":","StartElementHandler","EndElementHandler","CharacterDataHandler"]
docstr: 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
docstr_tok: ["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"]
code: def parse(self, 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
      """
      if (
          int(string is not None)
          + int(fptr is not None)
          + int(fname is not None)
          != 1
      ):
          raise ValueError(
              "Exactly one of fptr, fname, string must be specified."
          )
  
      if string is not None:
          fptr = BytesIO(string)
      elif fname is not None:
          fptr = open(fname)
  
      # store the name of the xml file in case it is needed during parsing
      self.fname = getattr(fptr, "name", None)
      parser = self._create_parser()
      for name in self.HANDLER_NAMES:
          setattr(parser, name, getattr(self, name))
      parser.ParseFile(fptr)
  
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 3 for calling the XmlParser obj's underlying member method code with example usage: obj.parse(string, fname, fptr) without return types