June 2004
Intermediate to advanced
848 pages
21h 28m
English
This section walks through a code example of a SAX parser. Because we have already covered much of the background, it will seem shorter than the DOM example. Don't be fooled. The general skeleton of the code is as follows.
// import statements: see belowpublic class MySAXEcho extends DefaultSAXHandler { main(String[] args) { // get a Parser // register my callbacks, and parse the file } // my routines that get called back public void startDocument() { /*code...*/} public void startElement( /*code...*/ public void characters ( /*code...*/ public void endElement( /*code...*/}
The first part of the program, the import statements, looks like this:
import java.io.*;import org.xml.sax.*; ...
Read now
Unlock full access