我总共有近15MB的xml数据。我想同时下载和解析。我正在使用http post请求来下载数据。下面是在我的方式为数据请求的代码::>增量xml数据分析iphone中的发布请求数据
NSString *soapMessage = [NSString stringWithFormat:
@"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:q0=\"http://medicineinfo.mss.uks.com\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> "
"<soapenv:Body> "
"<q0:getMedicineInfo> "
"<q0:device_id>%@</q0:device_id> "
"<q0:version_number>%@</q0:version_number> "
"</q0:getMedicineInfo> "
"</soapenv:Body> "
"</soapenv:Envelope>",[logic getDeviceID],verNo];
[logic release];
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/MedicineInfoImpl", appDelegate.strServerPath]];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"urn:vwservices/mcfLoginService#DoLogin" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
if(theConnection){
NSLog(@"theConnection");
webData = [[NSMutableData alloc] init];
} else {
NSLog(@"theConnection is NULL");
}
但我想通过
xmlParser = [[NSXMLParser alloc] initWithStream:inputStream];
解析XML数据其实我想输入的数据保持到nsinputstream。 我无法找到如何通过http post请求解析initwithStream。
在此先感谢。
你确定你的意思是同步吗?我无法想象用户会在等待如此庞大的文件进行解析时悬挂应用程序而感到高兴,更不用说占用所有内存了。 – SomaMan
Sory,它将是异步的。 – Rajesh
所以你以前曾经问过4个问题,但从来没有接受任何答案,现在你希望人们花时间编写代码来帮助你? –