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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:51:55+00:00 2026-06-10T00:51:55+00:00

I am using TouchXML to parse XML. While i am running the same in

  • 0

I am using TouchXML to parse XML. While i am running the same in “Profile” Mode. I can able to see the memory leak. How can I fix this issue?

-(NSMutableArray *) grabXML:(NSData *)xmlData andQuery:(NSString *)query {  
    NSMutableArray *blogEntries = [[[NSMutableArray alloc] init] autorelease];  
    CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithData:xmlData options:0 error:nil] autorelease];
    NSArray *resultNodes = [rssParser nodesForXPath:query error:nil];
    for (CXMLElement *resultElement in resultNodes) {
        NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
        int counter;
        for(counter = 0; counter < [resultElement childCount]; counter++) {
            [blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
        }
        for( int i = 0; i < [[resultElement attributes] count]; i++) {
            CXMLNode *node = [[resultElement attributes] objectAtIndex:i];
            [blogItem setObject:[[resultElement attributeForName:[node name]] stringValue] forKey:[node name]];
        }
        [blogEntries addObject:[blogItem copy]];
        [blogItem release];
    }
    return [blogEntries copy];
}

I am calling the above method in the below mentioned format.

NSMutableArray *arr = [[self grabXML:responseData andQuery:@"//wsCheneliereResult"] autorelease];
  • 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-10T00:51:56+00:00Added an answer on June 10, 2026 at 12:51 am
    [blogEntries addObject:[blogItem copy]];
    

    Here is your mistake : you do not need to copy the blogItem, addObject: will actually retain its argument so that you can safely call [blogItem release]; afterward.

    And you most probably should not do return [blogEntries copy] either, and return just blogEntries : this is common programming habit that methods whose name does not contain ‘copy’ or ‘create’ return autoreleased values, such as you do not need to release them when you are done with them.

    To sum up, I would go with :

    -(NSMutableArray *) grabXML:(NSData *)xmlData andQuery:(NSString *)query {  
        NSMutableArray *blogEntries = [[[NSMutableArray alloc] init] autorelease];  
        CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithData:xmlData options:0 error:nil] autorelease];
        NSArray *resultNodes = [rssParser nodesForXPath:query error:nil];
        for (CXMLElement *resultElement in resultNodes) {
            NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
            int counter;
            for(counter = 0; counter < [resultElement childCount]; counter++) {
                [blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
            }
            for( int i = 0; i < [[resultElement attributes] count]; i++) {
                CXMLNode *node = [[resultElement attributes] objectAtIndex:i];
                [blogItem setObject:[[resultElement attributeForName:[node name]] stringValue] forKey:[node name]];
            }
            [blogEntries addObject:blogItem];
            [blogItem release];
        }
        return blogEntries;
    }
    

    and

    NSMutableArray *arr = [self grabXML:responseData andQuery:@"//wsCheneliereResult"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm able to successfully parse the contents of a XML file using TouchXML, but
I'm using TouchXML to parse an XML-stream the following way: CXMLDocument *parser = [[CXMLDocument
I have an xml I am using TouchXML to parse it. Basically, a Lookup
I'm trying to parse an XML document using TouchXML for iOS. Normally this works
I am trying to parse xml using the touchXML library but not getting the
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I'm using TouchXML to parse an RSS feed. It works pretty well until it
I'm trying to parse HTML using TouchXML . However, it seems that the data
got a little problem with receiving the contents of a xml file (using TouchXML).
<item> <data> <![CDATA[ <p>Test</p> <p><strong>Hi!</strong><br />Hello.</p> ]]> </data> </item> Using TouchXML/NSXMLParser How can i

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.