O'Reilly logo

XML Companion, The, Third Edition by Neil Bradley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required