gpt4 book ai didi

ios - 在 iOS (ipad/iphone) 中使用递归解析 XML

转载 作者:行者123 更新时间:2023-11-29 11:15:48 25 4
gpt4 key购买 nike

在使用 XML 的 iPad 应用程序中,我想了解使用递归解析 XML 文档是否会大量占用内存。我问这个是因为 xml 大约有 6 层深,为每个节点类型编写解析逻辑会很乏味。

预先感谢您对此的指导

最佳答案

我建议您不要使用 NSXMLParser(内部的)。

看这里:http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project .

我建议您使用 GDataXML(Google iOS 工具包的一部分)。它速度非常快,内存占用少且可靠。 http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/XMLSupport/

你可以做一些 XPath 来访问你在 xml 中的数据:

GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
GDataXMLElement *rootElement = [xmlDocument rootElement];

NSError *xPathError;
NSArray *objects = [rootElement nodesForXPath:@"//NodeA/NodeB" error:&xPathError];

如果您是 XPath 新手:检查 http://manual.calibre-ebook.com/xpath.html

问候

关于ios - 在 iOS (ipad/iphone) 中使用递归解析 XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9478579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com