i have used following code to parse the xml file but i can t get value...anyone can help me..? (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"Query"]) {
//Initialize the array.
appDelegate.books = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString:@"city"]) {
//Initialize the book.
aBook = [[Book alloc] init];
//Extract the attribute here.
aBook.bookID = [attributeDict objectForKey:@"name"];
//NSLog(@"Reading id value :%i", aBook.bookID);
}
//NSLog(@"Processing Element: %@", elementName);
}
您至少需要3个NSXMLParser委托才能正确解析XML-检查此处: http : //developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/XMLParsing/Articles/UsingParser.html查看实际说明。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.