I am using NSXmlParser for analysis via RSS feed. So far, everything is working.
I expect the rss feed will eventually contain tens / hundreds of messages. My current solution reads the entire rss feed and displays the results. However, I only want to read the first ten posts (to prevent it from parsing potentially hundreds of elements). Then at a later time (say, when the user reaches the end of the table) to analyze the next ten messages.
So my question is how I analyze the first ten messages, then analyze the next ten messages, then the next ten messages, and so on ...
Here is what I use to get ALL messages:
- (void)parseXMLFileAtURL:(NSString *)URL
{
myArray = [[NSMutableArray alloc] init];
NSURL *xmlURL = [NSURL URLWithString:URL];
rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[rssParser setDelegate:self];
[rssParser parse];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"item"]) {
item = [[NSMutableDictionary alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"item"]) {
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
[myTable reloadData];
}