-1

I am new in IOS. and i was looking for a tuto or small example in how to read from a local xml file in my ressources but i found nothing....any one with a good tuto or have worked with xml before i really need your help

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184

4 Answers4

0

Here you have the NSXMLParserDelegate doc with examples

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
0

You can use the following code for reading the xml file:

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myLocalXML" ofType:@"xml"];  
    if (filePath)
    {  
        NSString *myText = [NSString stringWithContentsOfFile:filePath];  
        if (myText)
       {  
            NSLog(@"XML : %@",myText);
            NSData *xmlData = [myText dataUsingEncoding:NSUTF8StringEncoding];
            NSXMLParser *parser = [[NSXMLParser alloc] initWithData:xmlData];
            parser.delegate = self;
            [parser parse];
        }  
    }  
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
0

the following link will help you adding parser provided by apple

http://www.edumobile.org/iphone/iphone-programming-tutorials/parsing-an-xml-file/

NSString *path = [[NSBundle mainBundle] pathForResource:@"Name of your xml here...." ofType:@"xml"];

use the e above code to access file from your project and provide it to above parser for parsing

Vinodh
  • 5,262
  • 4
  • 38
  • 68
0

TBXML is my favorite. You can download project from git hub.
And why is this my favorite is because it's easy to understand and also it's performance is high. Read this blog for more
How To Choose The Best XML Parser for Your iPhone Project

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184