Android Learning Note--xml

Source: Internet
Author: User

Transfer from http://blog.csdn.net/sam_zhang1984

There are two ways of parsing XML: SAX and DOM. They all have pros and cons.

The DOM is to load all the XML documents into memory and then treat them as a tree. The advantage is that it is more convenient to deal with trees, but the disadvantage is that if the XML file is larger, it will consume a large amount of memory;

SAX is a progressive scan of an XML document, line-by-row parsing, and can be processed in the process of XML documents at any point in time to abort the processing process, such as to find our target node, the remaining XML document content can not read, the direct end. The disadvantage is that the operation is relatively inconvenient, and the XML document processing, if modified, add, delete and other operations more inconvenient.

SAX is a standard interface for event-driven XML parsing. It works by reading the beginning and end of the document, the beginning and end of the tag element, the content entity, and so on, triggering the corresponding function, and we can do the processing we want to do in the corresponding function.

XML parsing mainly requires the following steps:

1. Create an event handler

2. Create a SAX parser

3. Assigning an event handler to a parser

4. Parse the document and send each event to the handler.

Android Learning Note--xml

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.