#define URIString @
"http://192.168.247.76:8899/hisyo_cn/test.xml"
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:URIString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:
15 ]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData=[[NSMutableData data] retain];
}
else
{
NSLog(@
"error" );
}
- (
void )connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [receivedData setLength:
0];
}
- (
void )connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [receivedData appendData:data];
}
- (
void )connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[connection release];
[receivedData release];
NSLog(@
"Error" );
[theContent setText:@
"Connection defeat" ];
}
- (
void )connectionDidFinishLoading:(NSURLConnection *)connection { NSString *content = [[NSString alloc] initWithData: receivedData encoding: NSUTF8StringEncoding]; NSLog(@
"content: %@",content);
[theContent setText:content];
xmlRead = [[NSXMLParser alloc] initWithData:receivedData];
[xmlRead setDelegate:self];
[xmlRead parse];
[connection release];
[receivedData release];
}