对于所有我正在尝试解析我的项目中的xml,但我有本地的xml解析的代码,我想要基于服务器的xml解析,我如何传递它
这是我想要使用的xml解析链接:
http://www.google.com/ig/api?weather=,,,50500000,30500000
这是我的xml解析,用于调用本地文件如何调用need服务器的xml链接进行解析。我需要不同类型的调用xml链接进行解析:
- (void)viewDidLoad
{
[super viewDidLoad];
_forecastInfo=nil;
currentcond=nil;
forecastcond=nil;
// Pass the NSData to the parser whether its from local file or its coming from web.... NSString *fileName=[[NSBundle mainBundle] pathForResource:@"weather" ofType:@"xml"];
NSData *data=[NSData dataWithContentsOfFile:fileName];
ForecastInfoParser *parser=[[ForecastInfoParser alloc]init];
parser.delegate=self;
[parser parseData:data];
}发布于 2011-07-18 13:13:42
NSURL *url = [[NSURL alloc] initWithString:@"hhttp://www.google.com/ig/api?weather=,,,50500000,30500000"];
NSData *data = [NSData dataWithContentsOfURL:url];
// 2 -- parsing
parser = [[MyParser alloc] init];
[parser parseXML:data];发布于 2011-07-18 13:27:08
NSString *URL=@"http://www.google.com";
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
NSURLResponse *resp = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest: theRequest returningResponse: &resp error: &err];
NSString * theString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
[resp release];
[err release];
NSLog(@"response: %@", theString);https://stackoverflow.com/questions/6728811
复制相似问题