0

In my

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

I check to see if one of my XML attributes is equal to a value I store in my plist. If it's not then I want it to execute normally and get the latest information. If it is the same value though I don't want to waste the processing time of getting all the data again. So if I have code like below how can I terminate the parsing process if the values are the same?

if (lastUpdated == [attributeDict valueForKey:@"last_updated"]) {
     // Terminate the xml parsing because data is up to date
}
daveomcd
  • 6,367
  • 14
  • 83
  • 137

3 Answers3

3

You can use [parser abortParsing] but note that this is intended for XML errors rather than "I don't want this data" situations and can cause your parser:parseErrorOcurred: method to be called a couple of times, in my experience.

jrturton
  • 118,105
  • 32
  • 252
  • 268
  • I don't think it's `parser:didFailWithError` I believe its `parser:parseErrorOccurred` ... at least that's what I'm using I couldn't find a reference to `parser:didFailWithError` – daveomcd Jul 15 '12 at 21:01
1

Call [parser abortParsing] to cancel parsing from current point.

Apurv
  • 17,116
  • 8
  • 51
  • 67
1

Just note that there is a bug in iOS 6.0 and abortParsing will cancel the parser but will not call parser:parseErrorOccurred and will not set 'parserError'.