Instance parsing method of parsing XML using pull parser in Android

1. Introduction to pull pull the pull parser is built-in in the Android system. The pull parser is similar to the Sax parser. It provides similar events, such as the start element and the introduction element. Use parser. Next() to enter the next element and trigger the corresponding event, and then carry out corresponding processing. When the element starts parsing, call perser. Nexttext() Method to get the value of the next text type element.

2. Pull features (1) a simple structure, an interface and a factory form a pull parser (2) it is easy to use. The pull parser has only one important method, next (), which is used to retrieve the next event, and there are only five events, start_ DOCUMENT,START_ TAG,TEXT,END_ TAG,END_ Document (3) has the minimum memory consumption. Like Sax parser, pull parser uses less memory temporarily, but Sax parsing is a little cumbersome and DOM consumes a lot of memory, so pull is recommended

3. The SRC structure project package is named com.pullxml.mypull, and the person.xml file exists in the SRC root directory

4. The sample pull parses XML. First create an android.xml in the SRC directory

Create a pullxmlservice

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>