Document handlers

In order for the application to receive basic markup events from the parser, the application developer must create a class that implements the DocumentHandler interface. This interface defines methods that handle different kinds of event:

void  startDocument() throws SAXException;
void  endDocument() throws SAXException;
void  startElement(String name, AttributeList atts)
                                     throws SAXException;
void  endElement(String name) throws SAXException;
void  characters(char ch[], int start, int length)
                                     throws SAXException;
void  ignorableWhitespace(char ch[], int start, int length)
                                     throws SAXException;
void  processingInstruction(String target, String data)
                                     throws SAXException;
void  setDocumentLocator(Locator myLoc);

Note that in SAX 2.0, ...

Get XML Companion, The, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.