-3

I use an API call which returns an XML file. I need to use the same multiple times. For e.g. on Click of Search button, call http://xyz.com/s1/?para1=srch

Then in a different view, call http://xyz.com/s2/?para2=set2

How should I implement the same? I mean should the XMLParser file be common for both the requests and just the if..else element names should be mixed in a single implementation of parser:didEndElement?

Please help me with an example.

hmthur
  • 1,032
  • 3
  • 13
  • 15

1 Answers1

0

Sure, you can re-use a parser if the page elements are the same. Just make a method in your parser's class that you can feed a location or xml file, and have it parse that file. Something like:

-(void)parseForecast:(NSData *)data; {
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
    [parser setDelegate:self];
    [parser parse];
    [parser release];
}

should do the trick.

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161