SAX (Simple API for XML), event-based XML Simple API, parsing XML documents is one of the two API.
2. Sax parsing
1. Use to the package:
javax.xml.parsers: parser factory tools
org.xml.sax: provides the core SAX API
2. Resolution Process
First of all build our parser, we need to inherit org.xml.sax.helpers.DefaultHandler class, covering one approach. Then to obtain SAX factory object, from the factory to obtain SAX parsing, the parser and parse the object (xml file) link to begin parsing, after the success of the last access to the properties can be resolved.
In reading the xml file parsing, when they read the corresponding content, corresponds to the event will be thrown by the ContentHandler method calls its corresponding response. DefaultHandler implements this interface ContentHandler, so DefaultHandler to serve as the default SAX2 event handler base class.
Common to the method:
(1) characters (char  ch, int start, int length)
Receive notification of character data elements available in this approach, the <xxx> </ xxx> added to the value between the properties.
(2) startElement (String uri, String localName, String qName, Attributes attributes)
Receive notification of the beginning elements of the parameter in the uri is the name of the domain, localName is the label name, qName is a modification of the label prefix, attributes that this tag contains a list of attributes.
(3) endElement (String uri, String localName, String qName)
Receive notification of the end element.
3. Export EXCEL
jxl.jar: provides a java tool for operational excel forms library
import jxl .*;
import jxl.write .*;
WritableWorkbook plan = Workbook.createWorkbook(new File("plan.xls")); // Create first paging, from 0 Start WritableSheet sheet = book.createSheet("name1", 0); // Parameters, respectively. : Columns, rows, , Value, this represents the fill Cap. 1 Column 1 row of cells , Subscripts start at 0 sheet.addCell(new Label(0, 0, "TYPE_ID")); ... plan.write(); plan.close();
4. Examples of the code
Reference to the annexes.