Saturday 12, Apr 2025
We are moved to new domain
Click -> www.ehowtonow.com
Sunday, 10 November 2013

SAX Parser Introduction


SAX – Simple API for XML

SAX parser work differently with DOM parser.SAX parser is faster and uses less memory than DOM parser.SAX don’t load and XML document into memory and don’t create any object representation of XML document instead, SAX is use the event-driven model its provides callback method and the parser invokes them as it reads the XML data. Using SAX parser you can’t  back up to an earlier part of document or rearrange it, any more than you can back up the serial data stream or rearrange characters you have read from than stream.

SAX will call listener object for following events:

  • startDocument
  • startElement
  • characters
  • comments
  • processing instructions
  • endElement
  • endDocument

SAX call back methods call the DefaultHandler (org.xml.sax.helpers.DefaultHandler).You should extend the Default handler override the following methods or use DefaultHandler as Inner Class.

Methods must be overridden are

  1. startDocument() and endDocument() – methods called at start and end of an XML document
  2. startElement() and endElement() – methods called at the start and end of each element.
  3. characters() – method called when text contents between start and end of element

See the SAX Parser example for more details Read XML File using Sax Parser

SAX is oriented towards state independent processing, where the handing of element does not depend  on the previous elements.

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer

Related Posts:

  • Read XML file using DOM Parser1In this tutorials we going to see how to read the XML document and iterate the nodes one by one using DOM parser 1. Create Project Called JavaXML. 2. Create package called com.javatutorialscorner.xml.dom under JavaXML. 3. Cre… Read More
  • Java XML IntroductionIn Tutorials we are going to see brief introduction about XML and its usage in Java.Java comes with set of API to process XML, we will see all the XML processing API available in JAVA in upcoming chapters.XML OverviewXML – Ex… Read More
  • Create XML File using DOM ParserIn this tutorials we going to see how to create the XML document using DOM parser 1. Create Project Called JavaXML. 2. Create package called com.javatutorialscorner.xml.dom under JavaXML. 3. Create Java class called CreateXML… Read More
  • SAX Parser Introduction SAX – Simple API for XML SAX parser work differently with DOM parser.SAX parser is faster and uses less memory than DOM parser.SAX don’t load and XML document into memory and don’t create any object representation of XM… Read More
  • Read XML File using DOM parserIn this tutorial we are going to see how to read XML file using DOM Parser. In this example I used to read XML document by Element Name.DOM parser parse the entire XML document and load it into memory.DOM parse the nodes as t… Read More
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: SAX Parser Introduction Rating: 5 Reviewed By: eHowToNow