XMLParser.m
//Parsing the Start of an Element
- (void)parser: (NSXMLParser *)parser didStartElement: (NSString *)elementName
namespaceURI: (NSString *)namespaceURI qualifiedName: (NSString *)qualifiedName
attributes: (NSDictionary *)attributeDict
{
if([elementName isEqualToString: @"Books"])
{
//Initialize the Array
appDelegate.books = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString: @"Chapters"])
{
//Initialize the Array
appDelegate.chapters = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString: @"Book"])
{
//Initialize the book
aBook = [[Book alloc] init];
//Extract the attribute here
aBook.bookID = [[attributeDict objectForKey:@"id"] integerValue];
NSLog(@"Reading id value :%i", aBook.bookID);
}
else if([elementName isEqualToString:@"Chapter"])
{
//Initialize the book
aChapter = [[Book alloc] init];
//Extract the attribute here
aChapter.chapter = [[attributeDict objectForKey:@"id"] integerValue];
NSLog(@"Reading id value :%i", aBook.bookID);
}
NSLog(@"Processing Element: %@", elementName);
}
// Parsing an elements value
- (void)parser: (NSXMLParser *)parser foundCharacters

NSString *)string
{
if(!currentElementValue)
currentElementValue = [[NSMutableString alloc] initWithString:string];
else
[currentElementValue appendString:string];
NSLog(@"Processing Value: %@", currentElementValue);
}
//Parsing the end of an element
- (void)parser: (NSXMLParser *)parser didEndElement: (NSString *)elementName
namespaceURI: (NSString *)namespaceURI qualifiedName: (NSString *)qName
{
if([elementName isEqualToString:@"Books"])
return;
//There is nothing to do if we encounter books elemnt
//If we encounter the book element however we want to add the book object
//to the array and release the object
else if([elementName isEqualToString:@"Book"])
{
[appDelegate.books addObject:aBook];
[aBook release];
aBook = nil;
}
else
[aBook setValue:currentElementValue forKey:elementName];
[currentElementValue release];
currentElementValue = nil;
}
RootViewController.m (This is for my book titles)
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
srvController = [[SecondRootViewController alloc] initWithNibName:@"SecondRootView" bundle:[NSBundle mainBundle]];
//Something here will get you to the second view details!!!
/*
Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
srvController.aBook = aBook;
*/
//Prepare to tableview.
SecondRootViewController *srvController = [[SecondRootViewController alloc] initWithNibName:@"SecondRootViewController" bundle:[NSBundle mainBundle]];
//Push the new table view on the stack
[self.navigationController pushViewController:srvController animated:YES];
}
SecondRootViewController.m (this is for my chapters)
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView

UITableView *)tableView cellForRowAtIndexPath

NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}