XML data parsing (element attributes) Sax Mode Nsparser Proxy

Source: Internet
Author: User

The XML document Format used in this article

SAX parsing XML data is a row-by-row resolution , unlike DOM's way of adding an entire document to memory resolution ,

SAX parsing using the NSParser(Apple's own framework ) DOM relies on GData ( google dev )

SAX Parsing Data principle : event -driven, each element is found to notify the agent , in the proxy method will find the elements encapsulated stored in the dictionary , we walk through the dictionary to find each element , stored in the data source array after modeling

The SAX parsing code for this XML document is given below, and the rest of the code is the same as the Previous few articles

SAX parsing commonly used proxy methods :(are proxy methods , the parser discovers a data to notify the corresponding agent method , event-driven )

The execution order of the methods is printed in pairs, and the discovery document corresponds to the End document, and the element is found to correspond to the end of the element.

Execute the appropriate code in the appropriate way, depending on the situation and the needs of the selection . The previous article chose didstartelement to implement the data modeling operation and found a sub-element ( video) with element (VIDEOS) creates a model , passes the data, and adds it to the array . how many arrays of video elements in the XML document correspond to the lengths of

Here's a separate way to say this :

The other parameters in this method do not know what to do , only to find that the dictionary has the data we need

This article uses the XML form, this article uses the method is didstartelement, This method notifies the agent when the parser discovers the element , the automatic invocation , we can get the value of the property with the element at this time ,

This is the XML data to be used in the next article , and we need to get to the content of the element , not the element ( element attribute ). Be aware of the two forms of XML that distinguish between What data we need , what data elements (attributes) are needed, or meta-content . The format of the document is different, the data we need is locked in a different location, which means that the way we parse it will be different .

XML data parsing (element attributes) Sax Mode Nsparser Proxy

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.