Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:13:22+00:00 2026-06-06T09:13:22+00:00

I want to use a web service and grab the data from the service.

  • 0

I want to use a web service and grab the data from the service. I am able to send the request and receive the data but help me with parsing it. heres my code. I want to parse the XML response and store it in a array for further use

-(void)performSearch:(NSString *)searchText
{
    NSString *param = [NSString stringWithFormat:@"ZIP=%@",
                       searchText];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityForecastByZIP?%@", param]];

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setRequestMethod:@"GET"];

    [request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];

    NSLog(@"%@",param);

    NSLog(@"%@",url);


    NSLog(@"%@",request);
    [request setDelegate:self];
    [request startAsynchronous];

    }
- (void)requestFinished:(ASIHTTPRequest *)request
{
    NSData *response = [request responseData];

    NSLog(@"%@",response);
help me how to parse the data and store it in array 
    //NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:response];


     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:13:23+00:00Added an answer on June 6, 2026 at 9:13 am

    There are plenty of good tutorials for learning how to properly parse XML, here’s a quickie:

    in .h

    @interface ObjectName : ObjectSuperclass <NSXMLParserDelegate> {
        NSMutableString *currentElement;
        NSMutableString *childElement;
        NSMutableDictionary *array;
        NSXMLParser *parser;
    }
    
    @end
    

    in .m:

    -(void)parseWithData:(NSData *)data {
        parser = [[NSXMLParser alloc] initWithData:data];
        [parser setDelegate:self];
        //You might want to consider additional params like:
        [parser setShouldProcessNamespaces:NO];
        [parser setShouldReportNamespacePrefixes:NO];
        [parser setShouldResolveExternalEntities:NO];
        //And then finally (which activates the delegates):
        [parser parse]; 
     }
    

    Again in .m, insert these NSXMLParser Delegate Methods:

    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{    
      currentElement = nil;
      currentElement = [elementName copy];
      if ([elementName isEqualToString:@"xmlParentElement"]) {
        //This means the parser has entered the XML parent element named: xmlParentElement
        //All of the child elements that need to be stored in the array should have their own IVARs and declarations.
        childElement = [[NSMutableString alloc] init];
      }
    }
    
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
      //For all child elements, run this if statement.
      if (currentElement isEqualToString:@"childElement") {
        [childElement appendString:string];
      }
    }
    
    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{   
      if ([elementName isEqualToString:@"xmlParentElement"]) {
        [array addObject:childElement];
      }
    }
    

    Feel free to comment if things are unclear!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want use some data from a website with web service. i have a
I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class
I want to use twitter web service in my silverlight application but don't know
I want to use a SOAP-based web service in Android, but I don't know
I've generated .class files from a web service. Now I want to use them
I want to use jQuery function to fetch web service response but getting error
I'm using Grails and want to use groovyws to call an web-service. But my
I have web service which i want to use to upload image to the
I want to use an AES 256-bit web service with a Windows Mobile 6.1
I'm having a web service witch I want to use on several domains. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.