Tuesday, 30 April 2013

What is NSDictionary?

If you are parsing xml data on your iOS program, please keep in mind that the code is slightly different when read xml file local from when you read it from a server.


Parsing Local XML file: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{
   
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


Parsing  XML file from Server: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{    
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


   NSURL *url = [NSURL URLWithString:urlString];
    NSXMLParser parser = [[NSXMLParser alloc]initWithContentsOfURL: url];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


If you have any Questions please comment.


written by: infinitywebseo

No comments:

Post a Comment