Simple SAX Example
This example creates a Java program that you can run from the command line. You will be able to specify an XML document to be parsed, and messages will be output onscreen in response to events generated by the SAX parser.
Note
Java, like XML, is case sensitive. All names of interfaces, classes, and so on in the following code must use the correct case if your application is to run correctly. |
Listing 18.2 shows a simple SAX example.
Listing 18.2. myHandler.java: A Java Program That Provides Screen Output in Response to SAX Events
import org.xml.sax.XMLReader; import org.xml.sax.SAXException; import org.xml.sax.Attributes; ... |
Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.