Search code examples
objective-ciosnsxmlparsernsbundle

Reading XML File from Server


I'm currently parsing an XML file that resides in my bundle using NSXMLParser with the following line:

NSURL *xmlURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"XMLFileName" ofType:@"xml"]];

But I want to put the same file on my server instead. I can't find an example of how to call the same file from my server. Any help is appreciated. lq


Solution

  • NSURL has several methods for creating URLs, one of which is -URLWithString:; like so:

    NSURL *xmlURL = [NSURL URLWithString:@"http://example.com/example.xml"];
    

    That URL can be passed directly to NSXMLParser; but you might want to do so in a secondary thread.