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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:29:13+00:00 2026-05-22T01:29:13+00:00

I want to check a data version number in my XML and if the

  • 0

I want to check a data version number in my XML and if the XML’s version number is newer then the user’s current version (saved in NSUserDefaults), the XML is parsed and inserted into the SQLite store, otherwise parsing is stopped and nothing happens.
I’ve got the parsing and storing part figured out, but I can’t figure out how to stop the XML parsing once started.

My XML Looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<DBName.sqlite>
  <data version="1">
    <rows>
      <row>
        <someInt>0</someInt>
        <someString>Howdy</someString>
        <rowVersion>0</rowVersion>
      </row>
      ...
    </rows>
  </data>
</DBName.sqlite>

So what I’m trying to do is to stop the NSXMLParser if the user’s previously stored dataversionCode == the XML dataversionCode.

My parsing method looks like this:

- (BOOL)parseXMLFileAtURL:(NSURL *)URL parseError:(NSError **)error {

    BOOL result = YES;

    NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
    [parser setDelegate:nil];

    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    [parser parse];

    NSError *parseError = [parser parserError];
    if (parseError && error) {
        *error = parseError;
        result = NO;
    }

    [parser release];
    return result;
}

Any help is appreciated. lq

I found a solution, thanks to Rob Napier’s nudge:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {

    if (qName) {
        elementName = qName;
    }

    if ([elementName isEqualToString:@"data"]) {

        int dataVersion = [[attributeDict objectForKey:@"version"] intValue]; 

        // Match dataVersion with whatever desired value

        if (dataVersion <= someValue) {
            [parser abortParsing];
        }

    }

    . . .

}
  • 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-22T01:29:14+00:00Added an answer on May 22, 2026 at 1:29 am

    Implement a delegate (which you’ll need anyway). In the delegate, when you parse the version if it is not what you want, then call [parser abortParsing].

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

Sidebar

Related Questions

Before Entering data into a database, I just want to check that the database
i retrieve data from upc database and then want to insert the data into
I am writing some data access code and I want to check for potentially
I have this script that collects data from users and I want to check
I want to compare two ms-access .mdb files to check that the data they
I want to check the login status of a user through an ajax request.
I want to use Git to store and version data efficiently, but I also
I want to check if an IEEE754 32-bit number has the value of exactly
I want to check out all files in all subdirectories of a specified folder.
I want to check for the existence of a table with a given ID

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.