标签:
6。-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{    
              NSMutableData *data=[[NSMutableData alloc]init];    
              self.receivedData=data;
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{    
             [self.receivedData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{    
 
             GDataXMLDocument *document=[[GDataXMLDocument 
alloc]initWithData:self.receivedData options:0 error:nil];               
                       GDataXMLElement *root=[document rootElement];    
              NSArray *array=[root elementsForName:@"news"];    
           for (GDataXMLElement *element in array) {                
                       GDataXMLElement *title1=[element elementsForName:@"title"].lastObject;        
                       GDataXMLElement *time1=[element elementsForName:@"time"].lastObject;        
                       GDataXMLElement *ID1=[element elementsForName:@"id"].lastObject;        
                       News *news=[[News alloc]init];        
                       news.title=[title1 stringValue];        
                       news.time=[time1 stringValue];        
                       news.newsID=[ID1 stringValue];        
                       [self.mutableArray addObject:news];    
                }       
    }
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4461038.html