XMLReader (interface)

The SAX parser implementation, parses the document returning information to the different handlers.

try {
  XMLReader parser = XMLReaderFactory.createXMLReader();
  parser.setContentHandler( new TestContentHandler());
  parser.parse( "test.xml");
} catch ( SAXException e) {
  • Parses the document identified by the systemId URI.

    parse( String systemId)
  • Parses the document identified by the InputSource object.

    parse( InputSource input)
  • Register an application specific XML content event handler.

    get/setContenHandler( ContentHandler handler)


    Ignores all content events if no ContentHandler defined.
  • Register an application specific error handler.

    get/setErrorHandler( ErrorHandler handler)


    Only reports fatal-errors (well-formedness) and ignores all other errors silently if no ErrorHandler defined.
  • Register an application specific entity resolver, used to resolve external entities.

    get/setEntityResolver( EntityResolver resolver)


    Uses built in external entity resolution mechanism if no EntityResolver supplied.
  • Register an application specific DTD event handler.

    get/setDTDHandler( DTDHandler handler)


    Ignores all DTD events if no DTDHandler supplied.
  • Enable/Disable a specific XML Reader feature.

    get/setFeature( String name, boolean value)
  • Set the value of a specific XML Reader property.

    get/setProperty( String name, String value)

Tip: Create your own XML Reader to treat other formats (CSV/Java Objects) like they were XML.