package com.kermit.sax;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
public class Demo01 {
public void read() throws Exception, SAXException {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setContentHandler(new BeanListHandler());
reader.parse("src/Book.xml");
}
}
class BeanListHandler extends DefaultHandler {
}
Sax解析代码片段
最新推荐文章于 2023-03-09 14:05:34 发布