简体   繁体   中英

How can I import data from an xml file and parse them in a NSCombobox using cocoa?

Hi I want to parse data from an xml file into a combobox using cocoa. I didn't find how to import data from my xml file. Can anyone help me please?

To import data into NSDate object you can use something like this:

NSString* path = [[NSBundle mainBundle] pathForResource: @"xmlfile" ofType: @"xml"];
NSData* data = [NSData dataWithContentsOfFile: path];

For parsing xml you can use NSXMLParser or some 3rdparty code like, for example: TBXML.
With TBXML you can load xml like this:

TBXML * tbxml = [[TBXML alloc] initWithXMLFile:@"books.xml"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM