3個級別,我有獲得A-的價值問題> 1,2,3,4 & B-> 1,2,3,4NSXML解析器高達上iphone
我必須在顯示這些數據3桌
表1)A,B 表2)當用戶點擊A - >他可以看到1,2,3,4以表格形式 但我的情況我只能顯示A的最後一個值即,4(未1,2,3)
如何解析所有1,2,3,4-
<?xml version="1.0" encoding="UTF-8"?>
<hall>
<movie Name="A">
<stall Name="1">
<description>qwe.</description>
<rating>5</rating>
</stall>
<stall Name="2">
<description>wer.</description>
<rating>5</rating>
</stall>
<stall Name="3">
<description>wer.</description>
<rating>5</rating>
</stall>
<stall Name="4i">
<description>wer.</description>
<rating>5</rating>
</stall>
</movie >
<movie Name="B">
<stall Name="t1">
<description>wer.</description>
<rating>5</rating>
</stall>
<stall Name="2">
<description>wer.</description>
<rating>5</rating>
</stall>
<stall Name="3">
<description>wer.</description>
<rating>5</rating>
</stall>
<stall Name="4">
<description>wer.</description>
<rating>5</rating>
</stall>
</movie>
</hall>
#
最新通報
#我的問題是我不知道如何分離電影名A和B的數據
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"hall"])
{
movieList = [[NSMutableDictionary alloc]init];
appDelegate.books = [[NSMutableArray alloc]init];
appDelegate.HospN = [[NSMutableArray alloc]init];
}
else if([elementName isEqualToString:@"movie"])
{
currentMovie = [[NSString alloc] initWithString:[attributeDict objectForKey:@"Name"]] ;
[appDelegate.books addObject:[attributeDict objectForKey:@"Name"]];
//[aBook.movie addObject:[attributeDict objectForKey:@"Name"]];
NSLog(@"Processing Value: %@", currentMovie);
//aBook.testament=currentMovie;
aBook.stall = [attributeDict objectForKey:@"name"];
NSLog(@"Movie A name : %@",[movieList objectForKey:@"A"]);
}
else if([elementName isEqualToString:@"stall"])
{
[appDelegate.HospN addObject:[attributeDict objectForKey:@"Name"]];
NSLog(@"Processing stall Value: %@", currentElementValue);
NSLog(@"appDelegate.HospN: %@", appDelegate.HospN);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if(!currentElementValue)
currentElementValue = [[NSMutableString alloc] initWithString:string];
else
[currentElementValue appendString:string];
//NSLog(@"Processing Value: %@", currentElementValue);
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if([elementName isEqualToString:@"hall"])
{
//NSLog(@"Movie List : %@",movieList);
}
else if([elementName isEqualToString:@"movie"])
{
[movieList setObject:appDelegate.books forKey:currentMovie];
NSLog(@"Movie name : %@",appDelegate.books);
NSLog(@"Movie A name : %@",[movieList objectForKey:@"A"]);
[currentMovie release];
//[stallNames release];
currentMovie = nil;
//stallNames = nil;
}
else if([elementName isEqualToString:@"stall"])
{
//you can populate other attributes here if stall is not just string but a modal class.
}
else
[aBook setValue:currentElementValue forKey:elementName];
[currentElementValue release];
currentElementValue = nil;
}
我陣列我appDelegate.HospN:值( 1 , 2, 3, 4i, t1, 2, 3,) **但我想去砍數據= 1,2,3,4i
和B = t1,2,3,4 **
Updtate如何獲得描述和評分的價值?
else if([elementName isEqualToString:@"description"])
{
NSLog(@"desp List : \n%@\n",currentElementValue);// i can see all value but how to chop data based on A and B
[movieList setObject:currentLink forKey:@"description"];
[appDelegate.despArray addObject:[movieList copy]];
NSLog(@"adding story: %@",currentLink);
}
else if([elementName isEqualToString:@"rating"])
{
}
感謝,但怎麼知道沒有行的時候對電影的用戶點擊和影片B sicne它們是不同的? – prajakta 2011-04-21 01:51:39
你可以...做到這一點[movieList objectForKey:@ 「A」] --->這將返回攤位的數組,然後你將不得不使用.. [movieList objectForKey:@ 「A」]計數。 – Ravin 2011-04-21 03:33:21
我做了我最好的,但沒有工作... :(我不能去高達3個levls – prajakta 2011-05-05 02:20:44