2012-12-17 33 views
1

我解析一个XML文件,一切都很完美,我看到的文件与NSLog,我也看到了解析的结果,但是当我转移我需要的标记到NSMutableArray,结果很奇怪。解析一个XML到一个NSMutableArray

-(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 

namespaceURI:(NSString *)namespaceURI 
    qualifiedName:(NSString *)qName { 
    if ([elementName isEqualToString:@"nom"]) { 
     // displays the Content of the tag 
     NSLog(soapResults); 
     // add the content of the tag to the NSMutableArray 
     [mySuppliers addObject:soapResults]; 
     // displays the NSMutable Array 
     NSLog(@"array: %@", mySuppliers); 
     [soapResults setString:@""]; 
     elementFound = FALSE; 
     // displays the count of the NSMutable Array 
     NSLog(@"NUMBER %d", [mySuppliers count]); 
} 
.... 

的输出是:

2012-12-16 22:00:03.140 StartProj[11698:c07] ABC 
2012-12-16 22:00:03.140 StartProj[11698:c07] array: (
    "ABC" 
) 
2012-12-16 22:00:03.140 StartProj[11698:c07] NUMBER 1 
2012-12-16 22:00:03.141 StartProj[11698:c07] ABBOTT 
2012-12-16 22:00:03.141 StartProj[11698:c07] array: (
    "ABBOTT ", 
    "ABBOTT " 
) 
2012-12-16 22:00:03.141 StartProj[11698:c07] NUMBER 2 
2012-12-16 22:00:03.142 StartProj[11698:c07] ACCESSORIES 
2012-12-16 22:00:03.142 StartProj[11698:c07] array: (
    ACCESSORIES, 
    ACCESSORIES, 
    ACCESSORIES 
) 
2012-12-16 22:00:03.142 StartProj[11698:c07] NUMBER 3 
+0

你在哪里分配数组。 – Girish

+0

你是否得到了解决方案? –

回答

0

更好可以分配的NSMutableDictionary添加的每个元素之后,词典]最后字典项目转移到nsmutable阵列。 enter image description here

enter image description here

enter image description here