首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >iphone中xml服务器的xml解析

iphone中xml服务器的xml解析
EN

Stack Overflow用户
提问于 2011-07-18 13:04:59
回答 2查看 224关注 0票数 0

对于所有我正在尝试解析我的项目中的xml,但我有本地的xml解析的代码,我想要基于服务器的xml解析,我如何传递它

这是我想要使用的xml解析链接:

http://www.google.com/ig/api?weather=,,,50500000,30500000

这是我的xml解析,用于调用本地文件如何调用need服务器的xml链接进行解析。我需要不同类型的调用xml链接进行解析:

代码语言:javascript
运行
复制
- (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]; 
}
EN

回答 2

Stack Overflow用户

发布于 2011-07-18 13:13:42

代码语言:javascript
运行
复制
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];
票数 0
EN

Stack Overflow用户

发布于 2011-07-18 13:27:08

代码语言:javascript
运行
复制
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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6728811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档