나는 나의 nsxmlparser 잘 뉴스 피드를 구문 분석이 : 그러나NSXMLParser 구문 분석 RSS는
http://www.skysports.com/rss/0,20514,12433,00.xml
를 내가는 각 항목의 출력을받을 있지만, 내 사용자 지정 개체로 저장 할 때 xml은 마지막으로 발생하는 레코드 하나만 저장합니다.
내 코드를 참조하십시오 :
-(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"rss"]) {
currentNews = [[NewsParse alloc] init];
}
}
-(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"description"]) {
currentNews.newsTitle = currentNodeContent;
NSLog(@"description = %@",currentNodeContent);
}
if([elementName isEqualToString:@"rss"])
{
[news addObject:currentNews];
[currentNews release];
currentNews = nil;
[currentNodeContent release];
currentNodeContent = nil;
}
}
이 방법은 트위터 피드와 함께 잘 작동하지만, XML이 다르게 나는 그것이 동작하지 않습니다 형성되기 때문에 지금은 있으리라 믿고있어.
나는 여전히 어떤 도움이 RSS를 보면 :
'[NewsParse alloc]'에'init' 이 누락 된 이유가 있습니까? – Regexident
죄송합니다. 나는 그것을 놓쳤습니다. 걱정하지 않아도된다. – MrPink
'init'이 아마도 비어 있기 때문이다. 대답을 오도하지 않도록 질문에서 정정해야합니다. – Regexident