為什么沒(méi)有輸出
package com.liu.test;
import java.io.IOException;
import com.liu.handler.*;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
import com.sun.org.apache.xml.internal.resolver.readers.SAXParserHandler;
public class SAXtest {
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
//獲取一個(gè)saxparserfactory的實(shí)例
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
SAXParserHandler handler = new SAXParserHandler();
parser.parse("books.xml", handler);
}
}
package com.liu.handler;
import jdk.internal.org.xml.sax.Attributes;
import jdk.internal.org.xml.sax.SAXException;
import jdk.internal.org.xml.sax.helpers.DefaultHandler;
public class SAXParserHandler extends DefaultHandler {
public void startElement(String arg0, String arg1, String arg2,
Attributes arg3) throws SAXException {
// TODO Auto-generated method stub
super.startElement(arg0, arg1, arg2, arg3);
}
public void endElement(String arg0, String arg1, String arg2)
throws SAXException {
// TODO Auto-generated method stub
super.endElement(arg0, arg1, arg2);
}
/**
* 用來(lái)標(biāo)識(shí)解析開(kāi)始
*/
public void startDocument() throws SAXException {
// TODO Auto-generated method stub
super.startDocument();
System.out.println("SAX解析開(kāi)始");
}
/**
?* 用來(lái)標(biāo)識(shí)解析結(jié)束
?*/
public void endDocument() throws SAXException {
// TODO Auto-generated method stub
super.endDocument();
System.out.println("SAX解析結(jié)束");
}
??
}
2017-03-24
應(yīng)該是這些包吧
2017-03-23
import的包錯(cuò)了 刪除重新引包