I'm trying to parse some XML...an example item has a few elements: name, day, latitude, longitude.
In the parsing, things look (according to log entries) just fine, but when I go to recall the information, I can get name and day, but latitude and longitude are zero'd out. Not sure why it's treating them differently, thoughts? Here is the parser code, and how I'm trying to recall the data:
PHP Code:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if(!currentElementValue){
currentElementValue = [[NSMutableString alloc] initWithString:string];}
else{
[currentElementValue appendString:string];}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if([elementName isEqualToString:@"opentasks"])
return;
if([elementName isEqualToString:@"task"]) {
[appDelegate.openTasks addObject:aTask];
[aTask release];
aTask = nil;
}
else
[aTask setValue:currentElementValue forKey:elementName];
NSLog(@"Adding %@ as %@",currentElementValue,elementName);
//the above log entry shows correct value
[currentElementValue release];
currentElementValue = nil;
}
then later
PHP Code:
...
latitude.text = [NSString stringWithFormat:@"%f",aTask.latitude];
...
is back to 0.0000
Thanks so much for your help.