# Documentation: the xmlproc DTDParser APIs

The DTD parser is the module xmlproc uses to read XML DTDs. It has been separated out as a separate module in order to make it possible to use it for other things than merely parsing and validating XML documents.

Applications that wish to use the DTD parser should implement the DTDConsumer interface and use it to receive parse events.

## The DTDParser interface

The DTDParser is in the xml.parsers.xmlproc.dtdparser module and implements the following interface:

`def __init__(self):`
  Instantiates a DTD parser.
`def set_dtd_consumer(self,consumer):`
  Tells the DTD parser where to send DTD parse events. The consumer object must implement the DTDConsumer interface.
`def set_error_handler(self,err):`
  Tells the parser where to send error events.
`def set_internal(self,yesno):`
  Tells the parser whether to consider this an internal (1) or external (0) DTD subset. The default is to consider it an external subset.
`def set_inputsource_factory(self,isf):`
  Tells the parser which object to use to map system identifiers to file-like objects.
`def parse_resource(self,sysID,bufsize=16384):`
  Makes the parser parse the XML document with the given system identifier.
`def reset(self):`
  Resets the parser to process another file, losing all unparsed data.
`def feed(self,new_data):`
  Makes the parser parse a chunk of data.
`def close(self):`
  Closes the parser, making it process all remaining data. The effects of calling feed after close and before the first reset are undefined.
`def get_current_sysid(self):`
  Returns the system identifier of the current entity being parsed.
`def get_offset(self):`
  Returns the current offset (in characters) from the start of the entity.
`def get_line(self):`
  Returns the current line number.
`def get_column(self):`
  Returns the current column position.
`def set_error_language(self,language):`
  Tells the parser which language to report errors in. 'language' must be an ISO 3166 language code (case does not matter). A KeyError will be thrown if the language is not supported.
`def deref(self):`
  The parser creates circular data structures during parsing. When the parser object is no longer to be used and you wish to free the memory it has allocated, call this method. The parser object will be non-functional afterwards.