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 6547915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:53:18+00:00 2026-05-25T11:53:18+00:00

I have been battling this issue for a few days now and think I

  • 0

I have been battling this issue for a few days now and think I have located the problem…

I am using an ASIHTTPRequest method to connect to my php script that calls requests data from the database, from there I initiate the NSXMLParser delegates everything seems to work fine, I can even NSLog the results as they get parsed however it seems that when I try to put these results into a NSMutableArray the results dont seem to want to go into it.. I keep getting null values..

I am hoping someone can give me a reason why or if you can point me in a direction to finally get this problem solved because its becoming a real pain in the behind..

This is my parsing process

- (IBAction)setRequestString:(NSString *)string
{
    //set up address
    NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"http://127.0.0.1:8888/CodeTest/"];
    [databaseURL appendString:string];
    //call delegates
    NSURL *url = [NSURL URLWithString:databaseURL]; //LIVE mode
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request setDelegate:self];
    [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{     
    NSString *responseString = [request responseString]; //Pass request text from server over to NSString 
    NSData *capturedResponseData = [responseString dataUsingEncoding:NSUTF8StringEncoding]; 
    NSLog(@"%@", responseString);
    [self startTheParsingProcess:capturedResponseData];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
    NSLog(@"%@", error);
}





#pragma mark - Parsing lifecycle
//--- Start parsing process using NSXMLParser ---------------->>
- (void)startTheParsingProcess:(NSData *)parserData
{
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //incoming parserDatapassed to NSXMLParser delegate which starts parsing process 

    [parser setDelegate:self];
    [parser parse]; //Starts the event-driven parsing operation.
    [parser release];

    [self.tableView reloadData];

}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    if ([elementName isEqual:@"item"]) {
        // NSLog(@"Found title!");
        itemString = [[NSMutableString alloc] init];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    [itemString appendString:string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if ([elementName isEqual:@"item"]) {
        //NSLog(@"ended title: %@", itemString);
        [myDataArray addObject:itemString];
        NSLog(@"%@", itemString);
        NSLog(@"%@", myDataArray);

        //TODO: Test release on memory consumption etc
        [itemString release];
        itemString = nil;
    }
}
//--- Finish parsing process using NSXMLParser ---------------->>

Which prints this

2011-09-08 08:46:24.424 iCode[1209:207] <?xml version="1.0"?>
<entries>
        <item>Honda</item>
        <item>Nissan</item>
        <item>Mitsubishi</item>
        <item>Toyota</item>
        <item>Mazda</item>
</entries>
2011-09-08 08:46:24.426 iCode[1209:207] Honda
2011-09-08 08:46:24.426 iCode[1209:207] (null)
2011-09-08 08:46:24.427 iCode[1209:207] Nissan
2011-09-08 08:46:24.427 iCode[1209:207] (null)
2011-09-08 08:46:24.428 iCode[1209:207] Mitsubishi
2011-09-08 08:46:24.428 iCode[1209:207] (null)
2011-09-08 08:46:24.430 iCode[1209:207] Toyota
2011-09-08 08:46:24.431 iCode[1209:207] (null)
2011-09-08 08:46:24.431 iCode[1209:207] Mazda
2011-09-08 08:46:24.432 iCode[1209:207] (null)
  • 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-05-25T11:53:19+00:00Added an answer on May 25, 2026 at 11:53 am

    Your myDataArray is nil and you just need to allocate it somewhere like startTheParsingProcess:.

    Example:

    - (void)startTheParsingProcess:(NSData *)parserData
    {
        //You could release and create a new array like this example
        //or check if nil, and if nil create the array else remove all objects.
        [myDataArray release];
        myDataArray = [[NSMutableArray alloc] init];
    
        NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //incoming parserDatapassed to NSXMLParser delegate which starts parsing process 
    
        [parser setDelegate:self];
        [parser parse]; //Starts the event-driven parsing operation.
        [parser release];
    
        [self.tableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been battling with this issue for a couple of days now. I have
So I have been trying and battling with this for a few hours now.
I've been battling with this issue for over 2 weeks now and have gotten
Hey I have been battling with this problem for a while now. Perhaps there
I have been battling with this piece of code for literally days now... Would
So I have been battling this issue for awhile now and tried many different
I have a challenging problem I've been battling for some time now. The Problem:
I have been battling a problem now for about a week and it's really
Hi I have been battling with this issue all day. I have a vs2010
Have been trying to figure this problem out for a while now and was

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.