Created
February 19, 2012 06:50
-
-
Save wujun/1862295 to your computer and use it in GitHub Desktop.
parser xml file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)parseData | |
{ | |
//self.importCardArray = [NSMutableArray arrayWithCapacity:10]; | |
[self.xmlParser setDelegate:self]; | |
self.statusLabel.text= @"Storing the cards to the database..."; | |
BOOL xmlParsingOK = [self.xmlParser parse]; | |
if (xmlParsingOK) { | |
self.statusLabel.text= @"All entry successfully imported."; | |
} | |
else | |
{ | |
self.statusLabel.text= @"Error parsing the xml file."; | |
} | |
self.spinner.hidden= YES; | |
[self.spinner stopAnimating]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict | |
{ | |
// Parsing the header record for the subject information | |
if ([elementName isEqualToString:@"subject"]) { | |
self.importSubjectID = [attributeDict valueForKey:@"subjectID"]; | |
self.importSubjectDescription = [attributeDict valueForKey:@"subjectDescription"]; | |
self.customDictionaryURL = [attributeDict valueForKey:@"customDictionaryURL"]; | |
...my property assignments etc | |
} | |
// Parsing the header record for the locale information | |
if ([elementName isEqualToString:@"locale"]) { | |
...my property assignments etc | |
} | |
// Parsing the question and answers | |
if ([elementName isEqualToString:@"Entry"]) { | |
NSString *myQuestion = [attributeDict valueForKey:@"question"]; | |
NSString *myAnswer = [attributeDict valueForKey:@"answer"]; | |
NSString *myEntryType = [attributeDict valueForKey:@"entryType"]; | |
...my property assignments etc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment