Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > XML Code Examples

Simple sax handler

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Simple sax handler package com.ack.xml.jaxp; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; public class SimpleSaxHandler extends DefaultHandler { public void endDocument() throws org.xml.sax.SAXException { log( "finished parsing document" ); } public void startDocument() throws org.xml.sax.SAXException { log( "starting to parse document" ); } public void warning( SAXParseException exception ) throws SAXException { log( "Warning SAX Exception:" + "\nProblem at line " + exception.getLineNumber() + ", column " + exception.getColumnNumber() + "\nReason: " + exception.getMessage() ); } public void error( SAXParseException exception ) throws SAXException { log( "Error SAX Exception:" + "\nProblem at line " + exception.getLineNumber() + ", column " + exception.getColumnNumber() + "\nReason: " + exception.getMessage() ); } public void fatalError( SAXParseException exception ) throws SAXException { log( "Fatal Error SAX Exception:" + "\nProblem at line " + exception.getLineNumber() + ", column " + exception.getColumnNumber() + "\nReason: " + exception.getMessage() ); } private void log( String msg ) { System.out.println( "\n======================" ); System.out.println( msg ); System.out.println( "======================" ); } }