How to make a NSURL Request and parse the XML response?

#import "ViewController.h"
#import "XMLReader.h"

     //first you need to create a URL using String.
      NSURL *url = [NSURL URLWithString:@"feed://"];
      //Once you create a URL,you are ready make a request.
       NSURLRequest *request = [NSURLRequest requestWithURL:url];
       //After making request the apparent thing is expecting the response that may be expected response or an Error. so create those objects and initialize them with NULL.
        NSURLResponse *response = NULL;
NSError *requestError = NULL;
      //Once you have response with you, capture your responseData using NSData.
       NSData *responseData = [NSURLConnection sendSynchronousRequest:request        returningResponse:&response error:&requestError];

        //Convert the response data into response String.
NSString *responseString  = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

        //Now you can start parsing the data using XML parser. You need XML parser in-order to     use the below class method "dictionaryForXMLString"
NSError *parserError = NULL;

NSDictionary *xmlDict = [XMLReader dictionaryForXMLString:responseString error:NULL]; 

        //Once You have xmlDict handy, you can pass this to the any ViewController(like tableview) to populate the data.



  1. Why don't you attack a library file here?

  2. Can please attach the library file? or can explain the library file details?

  3. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online course

  4. Top SEO Company The best known mobile App design and development company based in Lahore Pakistan. Get applications for Android, iOS, HTML5, Windows.
    IOS Apps Development in Lahore