Lauren Quantrell
Lauren Quantrell

Reputation: 2669

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

Upvotes: 1

Views: 750

Answers (2)

Williham Totland
Williham Totland

Reputation: 29019

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.

Upvotes: 2

edoloughlin
edoloughlin

Reputation: 5891

If you want to HTTP GET the file from your server then you should look at NSURLConnection. It allows you to do synchronous or asynchronous HTTP requests.

Upvotes: 1

Related Questions