I'm not sure exactly if this is possible but I wanted to see if anybody can point me in the right direction.
So I'm using MGTwitterEngine and I want the XML parser to only add status messages that have a particular phrase or trend (#music). This way only statuses that contain that phrase are actually added to the Dictionary.
Here is the MGTwitterStatusesParser code:
Code:
- (void)parser:(NSXMLParser *)theParser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
// NSLog(@"Started element: %@ (%@)", elementName, attributeDict);
[self setLastOpenedElement:elementName];
if ([elementName isEqualToString:@"status"]) {
// Make new entry in parsedObjects.
NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
[parsedObjects addObject:newNode];
currentNode = newNode;
} else if ([elementName isEqualToString:@"user"]) {
// Add a 'user' dictionary to current node.
NSMutableDictionary *newNode = [NSMutableDictionary dictionaryWithCapacity:0];
[currentNode setObject:newNode forKey:elementName];
currentNode = newNode;
} else if (currentNode) {
// Create relevant name-value pair.
[currentNode setObject:[NSMutableString string] forKey:elementName];
}
}
Would I use Regex to parse the information before it adds the object? Or can the XML parser go one step further and parse that phrase before it's added?
Thanks!