SAX parsing tool - provided by Sun. Built into jdk. org.xml.sax.*
## SAXParser class: Used to read and parse xml file objects
f,
DefaultHandler dh) Method: Parse xml file
Use the specified DefaultHandler to parse the content of the specified file into XML.
For example:
{ 1.创建SAXParser对象 SAXParserparser=SAXParserFactory.newInstance().newSAXParser(); 2.调用parse方法 parser.parse(new File("./src/contact.xml"),new MyDefaultHandler()); } [一个类继承class类名(extends DefaultHandler) 在调用是创建传进去 DefaultHandler类的API: voidstartDocument() : 在读到文档开始时调用 voidendDocument() :在读到文档结束时调用 void startElement(String uri, String localName, String qName,Attributes attributes) :读到开始标签时调用 voidendElement(String uri, String localName, String qName) :读到结束标签时调用 voidcharacters(char[] ch, int start, int length) :读到文本内容时调用
##Next, Let's take an example to understand the process of sax parsing xml.
The above is the content of the sax parsing schematic diagram and technical introduction of xml parsing, more For related content, please pay attention to the PHP Chinese website (
#