SAX promotes a modular design of XML systems, since it places no requirement on parsers to provide particular data structures (such W3C's DOM) representing XML documents. Since parsers plug in to the API using a driver style API, different parsers can be used for different application environments.
For more information on SAX, see the SAX page.
Then provide an implementation of the DocumentHandler, to receive your parsing events. (For example, you can build a DOM parse tree by using a com.sun.xml.tree.XmlDocumentBuilder instance as your document handler). This will need to be able to make copies of AttributeList data provided by the parser.
Finally, package your XML data as an InputSource (or get its URL) and call Parser.parse to send a stream of parse events to your document handler.
Applications can also provide an EntityResolver to participate in resolving the entities required by the XML document being parsed, arranging to use local or replicated copies. Some resolvers may have intelligence to access catalogs mapping XML public identifiers to URIs other than the system ID (perhaps stored in a local repository or a Java resource). They may also use all the available MIME type information, such as character encodings.
Some XML documents refer to unparsed entities or to notations in their attributes. When working with such documents, you will need to provide a DTDHandler object in order to be notified of the notations and unparsed entities which were defined in the document type definition (DTD).