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

  • Home
  • SEARCH
  • 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 6751331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:54:51+00:00 2026-05-26T12:54:51+00:00

In my iOS application, I am parsing an XML from a SOAP based webservice

  • 0

In my iOS application, I am parsing an XML from a SOAP based webservice and I am storing it into the SQLITE database. The problem that I am facing it is that, it is very slow. It takes about 18 seconds for about 310 rows of data.

Here is what is a sample of my XML –

<return>
<batteryID>1234</batteryID>
<batteryVersionNum>1</batteryVersionNum>
<conceptCode>abc</conceptCode>
<conceptDescription>abc</conceptDescription>
<effectiveEndTime>2010-11-23</effectiveEndTime>
<effectiveStartTime>2010-11-23</effectiveStartTime>
</return>
<return>
<batteryID>2345</batteryID>
<batteryVersionNum>1</batteryVersionNum>
<conceptCode>bac</conceptCode>
<conceptDescription>bac</conceptDescription>
<effectiveEndTime>2010-11-23</effectiveEndTime>
<effectiveStartTime>2010-11-23</effectiveStartTime>
</return>

I use NSXML parser for parsing the XML. For every return tag() I encounter, I create a new instance of my entity –

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
    attributes:(NSDictionary *)attributeDict
{
    if ([elementName isEqualToString:@"return"])
    {
        // Blank lab panel object
        objLabPanel = [NSEntityDescription insertNewObjectForEntityForName:@"LabPanels" inManagedObjectContext:managedObjectContext];
        mainElement = elementName;
    }
}

Once I encounter a return end element (), I save the object to the database –

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    if ([elementName isEqualToString:@"return"])
    {
        [objPatient addLabPanelsObject:objLabPanel];

        // Save
        NSError *error = nil;
        BOOL saveObj = FALSE;
        saveObj = [managedObjectContext save:&error];

        if (saveObj == FALSE)
        {
            NSLog (@"Error: %@", error);
        }
    }
    else if ([elementName isEqualToString:@"batteryID"] && [mainElement    isEqualToString:@"return"])
    {
    objLabPanel.labPanelBatteryId = elementValue;
    }
    // getting other values from the xml
    . 
    .
    .
    }

Hence for every return tag I encounter, I do a save to the database and so for my 310 or so records, I would be saving it 310 times. So by doing a [managedObjectContext save:&error]; , I guess that it opens the database, saves the data and closes the database and hence it takes a lot of time. Am I right in thinking this way?

Is there a way I can save all the objLabPanel’s to an array and then do a bulk insert to the database i.e. bulk insert the entire array of objLabPanel’s into the SQLITE database at once?

It would be great if someone could help me out with this.

  • 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-26T12:54:51+00:00Added an answer on May 26, 2026 at 12:54 pm

    You should save your changes only after you finished importing all entries. No need to save it after every insert.
    Also read Core Data Programming Guide: Efficiently Importing Data

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

Sidebar

Related Questions

I'm working in an iOS application which uses libXML2 to read XML retrieved from
i am developping an ios application and i am parsing my xml with gdataxml,
I am developing an iOS Application which loads its content from an XML-file over
I am creating an iOS application that I need to connect to a database
I have an iOS application that downloads an xml file using: NSURL *queryURL =
I'm trying to write an iOS application that'll get data from a web server
I am newbie to IOS application development. I have to parse an XML document
I am working on an iOS project that loads UIImages from URLs in a
I'm making an iOS application that has an interface in the portrait view. However,
I am using ASIHTTPRequest in my IOS application to call a wsdl/SOAP web services.

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.