- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"item"])
{
flag = YES;
if (!currentProperty)
{
currentProperty = [[NSMutableString alloc]init];
curItem = [[NSMutableDictionary alloc]init];
}
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"item"]) {
[items addObject:curItem];
}
if (flag == YES)
{
if ([elementName isEqualToString:@"link"] ||
[elementName isEqualToString:@"description"] ||
[elementName isEqualToString:@"pubDate"] ||
[elementName isEqualToString:@"title"])
{
[curItem setObject:currentProperty forKey:elementName];
//NSLog(@"%@, %@",[curItem objectForKey:elementName],elementName);
}
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if(flag == YES)
self.currentProperty = [NSMutableString stringWithString:string];
}
- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
{
if (flag == YES)
{
NSString *string =[[NSStringalloc]initWithData:CDATABlock encoding:NSUTF8StringEncoding];
currentProperty = string;
// NSLog(@"%@",currentProperty);
}
}
能解析到XDATA的数据,NSLog方法也可以输出解析到的CurrentProperty,但是此时的内容并没有添加的字典中(CurItem),请问我的程序哪里出错了,应该不是currentProperty 被释放了,因为别的标签中的数据都可以加到CurItem中,请问哪里出问题了