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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:32:15+00:00 2026-06-08T17:32:15+00:00

I am currently working on an iPad project for which I need to process

  • 0

I am currently working on an iPad project for which I need to process large XML file into an SQLite backend. I currently have this working using the TBXML parser.

So all the logic is in place and in general the TBXML parser does the job it needs to do. Only problem I’m now encountering is that the XML files are getting too big and I am running out of memory. Because of this I thinking of switching to a SAX parser like the core NSXMLParser of something like Alan Quatermain’s AQXMLParser. However this will require me to redo all of my current logic that to some extent relies on functions provided by a DOM tree. This is something I’d rather not do.

So what I want to try and do is create a hybrid approach. Given my XML structure this should be possible. It’s basically a number of repeating “Record” elements. And within each record are various elements that can be repeating and nested.
In my current approach I parse the document and pass each record element to a function that processes it into the database. Given that this already exists I want to use this in my hybrid parsing approach.

This is what I want to achieve. Using a SAX parser I traverse my document. While traversing the document I build a Record element. Whenever I complete a record element I pass it along to the existing function that uses TBXML to process it. The SAX parser then continues to build the next record element. Key goals are to:
– Fix the memory footprint (it doesn’t need to the smallest it can be, but it has to be contstant or at least smaller that using TBXML)
– Keep performance acceptable.

Currently want to implement this as follows:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict{
    //Recreate record string each time record element is encountered
    if([elementName isEqualToString:@"Record"]) record = [[NSMutableString alloc] init];
    //Write XML tag with name
    [record appendFormat@"<%@>, elementName];
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    //Write XML content
    [record appendString:string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
    //Write XML tag
    [record appendFormat@"</%@>, elementName];
    if([elementName isEqualToString:@"Record"]){
        //Parse record string into TBXML object
        TBXML * tbxmlRecord = [TBXML tbxmlWithXMLString:record];
        //Send it to the TBXML record processor
        [self processElement:tbxmlRecord.rootXMLElement];
    }
}

I think this should work but it feels dirty to use a string. Furthermore I have my concerns on if the record string won’t get overwritten too soon when the parser reaches a new record element.

So my question is, if this is a sound way to approach this or if there are better ways for me to achieve what I’m looking for?

Edit:
I’ve implemented this approach and it looks to working quite well. Only hiccup I’ve encountered is that if my source file isn’t UTF-8 encoded I only get a partial result. But when I correct this all goes well. Memory usage isn’t that much better though. But maybe it takes what it can. Need to run more tests…

  • 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-08T17:32:16+00:00Added an answer on June 8, 2026 at 5:32 pm

    In general your approach sounds fine to me. If your solution is working for you without performance problems then I wouldn’t be too worried about the string handling. If you want to you can profile your application to see how much CPU time is wasted by this.

    If you want to do something slightly more optimized, you could try to find a SAX parser that gives you the byte offsets of the original buffer and combine this with a DOM parser that lets you work with non null-terminated C strings. I would believe this means you have to switch to a C or maybe C++ library. I have used rapidxml for something vaguely similar to what you are trying (xml chunks embedded in huge file).

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

Sidebar

Related Questions

I am working on an iPad application. In this I have to show some
Iam currently working on a iPad project where i build my code on top
I have a universal binary application and currently working on the iPad version of
I'm working on an iPad project, currently it's on Landscape view. And I tried
Currently i am working on a Location based application for iPhone/iPad . I have
I'm currently working on an iPad App and ran into the following Issue. When
i am currently working on an iPad application, my client wants to add Function
I'm currently working on an OpenGL ES 1.1 app for the iPad its running
I am working with the UISplitViewController in iPad application. Currently, I found two issues:
Currently working with converting SQLException error messages into messages that are more useful for

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.