XMLファイルコード:
<Books>
<Book id="1" isbn="123456">
<name>Let Us C</name>
<authors>
<author>Yashwant Kanetkar</author>
<author>ABC</author>
</authors>
<price>250.00</price>
</Book>
<Book id="2" isbn="345678">
<name>Programing With C++</name>
<authors>
<author>Balaguruswamy</author>
<author>XYZ</author>
</authors>
<price>400.00</price>
</Book>
<Book id="3" isbn="789012">
<name>Professional iPhone and iPad Application Development</name>
<authors>
<author>Gene Backlin</author>
<author>QWE</author>
</authors>
<price>550.00</price>
</Book>
<Book id="4" isbn="901234">
<name>Beginning iOS 4 Application Development</name>
<authors>
<author>Wei-Meng Lee</author>
<author>IOP</author>
</authors>
<price>500.00</price>
</Book>
</Books>
誰かplsはこれで私を助けることができますか?
私はこのコードを使用しています:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"Books"])
{
appDelegate.books = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString:@"Book"])
{
aBook = [[Book alloc] init];
aBook.bookID = [[attributeDict objectForKey:@"id"] integerValue];
aBook.isbn = [[attributeDict objectForKey:@"isbn"] integerValue];
NSLog(@"Reading isbn value : %@", aBook.isbn);
NSLog(@"Reading id value :%i", aBook.bookID);
}
NSLog(@"Processing Element: %@", elementName);
}