Ios-oc-xml parsing-Nsxmlparser

Source: Internet
Author: User

        // 4. Parsing Data         // 4.1 Creating an XML Parser: SAX        Nsxmlparser *parser = [[Nsxmlparser alloc]initwithdata:data];                 // 4.2 Setting up proxies        Parser. delegate = self ;                 // 4.3 start parsing, blocking        [Parser parse];



//1. When you start parsing XML documents-(void) Parserdidstartdocument: (Nsxmlparser *) parser{NSLog (@"%s", __func__);}//2. Start parsing an element-(void) Parser: (Nsxmlparser *) parser didstartelement: (NSString *) elementname NamespaceURI: (NSString *) NamespaceURI QualifiedName: (NSString *) QName attributes: (nsdictionary<nsstring *,nsstring *> *) attributedict{NSLog (@"start parsing%@---%@", elementname,attributedict); //filter the root element    if([ElementName isequaltostring:@"Videos"]) {        return; }        //Dictionary Turn Model[Self.videos addobject:[xmgvideo mj_objectwithkeyvalues:attributedict];}//3. An element parsing is complete-(void) Parser: (Nsxmlparser *) parser didendelement: (NSString *) elementname NamespaceURI: (NSString *) NamespaceURI QualifiedName: (NSString *) qname{NSLog (@"End parsing%@", elementname);}//4. End parsing-(void) Parserdidenddocument: (Nsxmlparser *) parser{NSLog (@"%s", __func__);}

Ios-oc-xml parsing-Nsxmlparser

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.