NSURLConnection In Objective C
{
[self.webResponseData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.webResponseData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"%@",error);
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *theXML = [[NSString alloc] initWithBytes:
[_webResponseData mutableBytes] length:[_webResponseData length] encoding:NSUTF8StringEncoding];
NSLog(@"theXML : %@",theXML);
NSData *myData = [theXML dataUsingEncoding:NSUTF8StringEncoding];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:myData];
xmlParser.delegate = self;
// Run the parser
@try
{
BOOL parsingResult = [xmlParser parse];
NSLog(@"parsing result = %d",parsingResult);
}
@catch (NSException* exception)
{
NSLog(@"%@",exception);
return;
}
}
Comments
Post a Comment
Thank You.