Loading
SAX PARSER

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is SAX parser ?


Ans)

The SAX specification defines an event-based approach whereby parsers scan through XML data,
calling handler functions whenever certain parts of the document (e.g., text nodes or processing
instructions) are found.

These events include the start and end of the document, finding a text node, finding child elements,
and hitting a malformed element. So the SAX parser doesn't create any internal representation of the
document. Instead, the parser calls handler functions when certain events
defined by the SAX specification) take place.

Here is the Example of Java Sax Parser:


public class Test extends DefaultHandler  {
        public static void main(String[] args) {
                try {
                        Test saxNames = new Test();
                        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
                        parser.parse(new File("C://document.xml"),saxNames);
                } catch (Exception e) {
                        e.printStackTrace(System.err);
                }
        }
        public void startElement(String uri, String localName, String qName,
                        Attributes attrs) {
          }
        public void endElement(String uri, String localName, String qName) {
        }
 }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

SAX PARSER


SAX PARSER

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free