0
我的XML格式是這樣創建磁盤陣列:從XML文件
<Rows>
<Row>
<style>String</style?
<thumbnail>String</thumbnail>
</Row>
<Row>
<style>String</style?
<thumbnail>String</thumbnail>
</Row>
</Rows>
如何創建一個NSMutableArray這樣的({風格=「值」;縮略圖=「值」;} ... ..)
這裏是我的代碼:
-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"style"]) {
element = [NSString stringWithString:elementName];
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
elementFound = YES;
}
if ([elementName isEqualToString:@"thumbnail1"]) {
element = [NSString stringWithString:elementName];
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
elementFound = YES;
}
}
-(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string
{
if (elementFound) {
[soapResults appendString:string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI: (NSString*)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"style"]) {
[rowDict setValue:soapResults forKey:@"style"];
elementFound = NO;
soapResults = nil;
}
if ([elementName isEqualToString:@"thumbnail1"]) {
[rowDict setValue:soapResults forKey:@"thumbnail1"];
elementFound = NO;
soapResults = nil;
}
}
我越來越如果我做這樣的格式錯誤,請幫我在廣告
謝謝萬斯。