在iOS sdk中parsing本地xml文件

我需要parsing一个本地的XML文件,这是在我的资源文件夹按UIButton时。 我知道如何parsing来自Web的XML文件。 现在我怎样才能显示在我的资源文件夹中的XML内容。

如何parsing本地XML文件?

我从你的标签中假设你正在使用NSXMLParser来parsingXML。 在这种情况下,你可以这样做:

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