iOS基础:NSXMLParser (SAX方式解析)

xiaoxiao2021-02-27  182

文章目录

I、使用步骤 II 、原生API解析XML

I、使用步骤

// 传入XML数据,创建解析器 NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; // 设置代理,监听解析过程 parser.delegate = self; // 开始解析 [parser parse];

NSXMLParser采取的是SAX方式解析,特点是事件驱动,下面情况都会通知代理

当扫描到文档(Document)的开始与结束 当扫描到元素(Element)的开始与结束

NSXMLParserDelegate

@protocol NSXMLParserDelegate <NSObject> @optional - (void)parserDidStartDocum #公众号:iOS逆向 认证博客专家 Swift SwiftUI Objective-C 微信公众号:【iOS逆向】iOS逆向与安全,熟悉iphone/tweak、iphone/tool、cydia的repo 制作 、cocoapods的Specs repo制作(using-pod-lib-create、private-cocoapods)。I am a software engineer currently living in Changsha. My interests range from technology to writing.
转载请注明原文地址: https://www.6miu.com/read-13264.html

最新回复(0)