how to parse 2 URL’s using NSXMLParser in the same file? I have tried it like this:
[self parseXMLFileAtURL:url1];
[self parseXMLFileAtURL:url2];
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//here both url's returns the same data (element names are same), so how will I differentiate data between first URL & second URL.
if(url1 data) {
//do something
}
if(url2 data) {
//do something
}
}
so help me to find a way to differentiate.
The first parameter called
parseris the current parser instance used.This is the way to know which file you are currently parsing.
Alloc/init two separate instances of
NSXMLParser, and start parsing your two files with.Assuming they are ivar a simple
==test would tell you which one is used.Here is a link to similar question.