1、SAX解析: DefaultHandler在 org.xml.sax.helpers 包中 建立 SAX解析器: Import org.xml.sax.helpers; public class MySAX extends DefaultHandler public void startDocument() throws SAXException System.out.println(“); public void endDocument() throws SAXException public void startElement(String uri,String localName,Str
2、ing qName,Attributes attributes) throws SAXException System.out.print(“); public void endElement(String uri,String localName,String qName) throws SAXException System.out.print(“); public void characters(char ch,int start,int length) throws SAXException System.out.print(new String(ch,start,length); JDOM: 通过 JDOM输出 XML 文件: SAXBuilder 在 org.jdom.input 包中: