The parsing XML of Android

Source: Internet
Author: User

1.XML: Extensible Markup Language.

Extensible Markup Language is a markup language that is much like a Hypertext markup language.

It is designed to transmit data instead of displaying data.

Its mark is not predefined. You need to define your own labels.

It is designed to be self-descriptive.

is the recommended standard.

Three ways to parse XML 2.Android

(1). Sax parsing

H t T P://w w W. C N B L og s. Co m/z ha n g m i ao 1 4/p/6 1 8 0 5. h T M l

(2). Dom parsing

H TT P://w w W. CN b Lo G S. C o m/z h an g M ia o 1 4/p/61 8 3 9 76. H T ML

(3). Pull parsing

H t T P://w W. C N B l o gs. C Om/zh a ng mi a O1 4/p/6 1 84 2 0 1. H T M l

3. Analysis of Technical Summary

For Android mobile devices, because the resources of the device is more valuable, memory is limited, so we need to choose the appropriate technology to parse the XML, so as to improve the speed of access.

(1). When the DOM is processing an XML file, it parses the XML file into a tree structure and puts it into memory for processing, and when the XML is compared to an hour, the DOM can be selected because it is simple and intuitive.

(2). Sax is a pattern of parsing an XML file with events, which transforms an XML file into a series of events that are determined by different event handlers. When the XML file is large, it is reasonable to choose Sax technology. Although the amount of code is somewhat large, it does not need to say that all XML files are loaded into memory. This is more efficient for limited Android memory, and Android offers a traditional sax usage and a handy sax wrapper. Using the Android.util.xml class is easier than using sax.

(3). XML pull parsing does not listen to the end of the element as sax parsing does, but rather completes most of the processing at the beginning. This facilitates early reading of XML files, greatly reducing parsing time, which is especially important for mobile devices with slow connection speeds. The XML pull parser is a more efficient method for XML documents that are large but require only a portion of the document.


The parsing XML of Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.