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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.