SAX is underneath most XML processing
by, 10-31-2011 at 06:08 PM (740 Views)
SAX is a simple API for XML and is largely used because it is very popular because almost all XML processing involves SAX at some level.
SAX is blazing fast and has been around for a while. XML is fairly easy to work with, but it's not an intuitive language in lots of ways. Most of the XML parsers these days use SAX since it already works pretty well.
SAX is great at parsing XML. And if you know how to handle errors in SAX, then you know how to handle errors in almost any XML processing API. SAX parsing obviously uses SAX.
The example below shows a fragment from a program that parses an XML document using SAX.
Java Code:XMLReader reader = XMLReaderFactory.createXMLReader(); ContentHandler handler = new PrintingContentHandler(); reader.setContentHandler(handler); reader.parse(new InputSource(new FileReader(xmlFilename)));