ParseTest.java



import javax.xml.parsers.*;
import org.xml.sax.*;

/** SAX Parse Test */
public class ParseTest {

  /** Reader */
    private XMLReader reader = null;

  /** Constructor */
    public ParseTest() {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();
                     // System.out.println( spf.toString() );
            SAXParser parser = spf.newSAXParser();
                     // System.out.println( parser.toString() );
            reader = parser.getXMLReader();
                     // System.out.println( reader.toString() );
            reader.setContentHandler( new MyContentHandler() );
            reader.setErrorHandler( new MyErrorHandler() );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }

  /** main (start here) */
    public static void main( String[] argv ) {
        try {
            ParseTest test = new ParseTest();
            InputSource source = new InputSource( argv[0] );
            test.reader.parse( source );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }
}