Name
ContentHandler
Synopsis
The ContentHandler is
the most used of the SAX handler objects. It is this handler that
receives information about the elements being parsed, their
attributes, and the content between start and end tags. The parse and parseString convenience functions described
in the previous section require a ContentHandler implementation to be passed
in.
setDocumentLocator(locator)SAX parsers are encouraged to supply a
locatorfor finding the origin of events within the document, so that you can determine the end position of any document-related event. Thelocatorobject conforms to theLocatorinterface, described later in this Appendix.startDocument( )When the parser begins a document, it calls this method first and only once, with the exception of
setDocumentLocator, which is called first if implemented.endDocument( )This method is called only once as the very last method invoked by the parser.
startPrefixMapping(prefix, uri)This method is called when a namespace declaration is encountered. The
prefixparameter is the prefix string used in the document, andurirefers to the Universal Resource Indicator (URI) that the prefix represents.endPrefixMapping(prefix)This event occurs at the time the end element with the corresponding
startPrefixMappingis called, indicating that the declaration forprefixhas gone out of scope. It does not indicate that there is no mapping forprefix; an outer declaration may still be in scope.startElement(name, attrs)This ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access