开发者

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] pa开发者_高级运维thForResource:@"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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜