Parsing Webservice data iOS

BESH0

New Member
Good Afternoon all ,I have downloaded data from a web service and im looking to parse that data so that i can use it , but I'm having problems parsing the returned values , below is the aquisition code and anything else in between ANY help would be appreciated \[code\] -(IBAction)runNewImport:(id)sender{recordResults = FALSE;soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<s:Envelope \n" "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n" "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \n" "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" \n" "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" "<s:Body> \n" "<[FUNCTION] xmlns=\"http://tempuri.org/\"/>\n" "</s:Body> \n" "</s:Envelope>"];[[NSURLCache sharedURLCache] removeAllCachedResponses];NSURL *url = [NSURL URLWithString:@"http://[PATH]"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: @"[FUNCTION]" forHTTPHeaderField:@"SOAPAction"];[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];[theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];if(theConnection) { webData = http://stackoverflow.com/questions/11139551/[NSMutableData data]; NSLog(@"%@",webData);}else { NSLog(@"theConnection is NULL");} }-(void)connectionDidFinishLoading:(NSURLConnection *)connection{NSLog(@"DONE. Received Bytes: %d", [webData length]);NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];NSLog(@"THIS IS THE DATA : %@",theXML);xmlParser = [[NSXMLParser alloc] initWithData: webData];[xmlParser setDelegate:self];[xmlParser setShouldResolveExternalEntities: YES];[xmlParser parse];}-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *) elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName attributes: (NSDictionary *)attributeDict{if( [elementName isEqualToString:@"CODE"]){ soapResults = [[NSMutableString alloc] init]; NSLog(@"%@",soapResults); recordResults = TRUE;}}-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *) elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{if( [elementName isEqualToString:@"CODE"]){ recordResults = FALSE; soapResults = nil; }}\[/code\]Thanks for looking and again , all help is welcome
 
Back
Top