Eight, the seventh day of Android learning--xml file parsing method

Source: Internet
Author: User

(Transferred from: http://wenku.baidu.com/view/af39b3164431b90d6c85c72f.html)

Eight, the seventh day of Android learning--xml file parsing method

XML file: Extensible Markup Language

Definition: Used to mark electronic files with a structured markup language that can be used to tag data, define data types, and is a source language that allows users to define their own markup language.

How to parse xml:

    • Sax--simple API for XML is both an interface and a package
      It uses event-driven, which parses an XML document and needs to parse the entire document, and during parsing, it determines whether the current character parsed matches a part of the XML, and if so, triggers the event if it does not, triggering the corresponding callback function if it does not conform. This callback function is encapsulated in the ContentHandler interface: Because ContentHandler is implemented will be forced to implement a lot of useless methods, so do not use this interface, we inherit the DefaultHandler class, because it implements the ContentHandler part of the method we need, save some of our useless methods oh. So choose to use this.
      The downside is that it can be laborious to use it to add or remove some content.
    • Dom--document Object Model
      This parsing method is to load a known XML document into memory and store it as a DOM tree, parsing the file based on the relationship between the DOM node and the child nodes, and if the file is too large, parsing can be time-consuming and resource-intensive.

Here are the main explanations for the process of Sax parsing XML files:

(i) Creating an event handler

(ii) Creating a SAX parser

(iii) Assigning an event handler to a parser

(iv) parsing the document and sending each event to the handler

Eight, the seventh day of Android learning--xml file parsing method (GO)

Related Article

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.