当按下 UIButton 时,我需要解析资源文件夹中的本地 xml 文件。我知道如何从网络上解析 XML 文件。现在如何显示资源文件夹中的 xml 内容。
如何解析本地 XML 文件?
最佳答案
我从你的标签中假设你正在使用 NSXMLParser 来解析 XML。在这种情况下,您可以这样做:
NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"xml"];
NSData *xmlData = [NSData dataWithContentsOfFile:xmlPath];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
// do whatever you want with xmlParser
关于objective-c - 在 iOS sdk 中解析本地 xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4918394/