1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- (void)requestFinished:(ASIFormDataRequest *)request
{
    if(i==0) {
        i++;
        // Use when fetching text data
        NSString *responseString = [request responseString];
        ElementParser * parser = [[ElementParser alloc] init];
        DocumentRoot* document = [parser parseHTML:responseString];
        NSArray* elements = [document selectElements:@"a"];
        for(Element* element in elements) {
            snippet = [element attribute:@"href"];
            UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"URL" message:snippet delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
            [alert show];
            [alert release];
            
            NSURL *final = [NSURL URLWithString:snippet];
            requestt = [ASIFormDataRequest requestWithURL:final];
            [requestt setDelegate:self];
            [requestt startAsynchronous];
            
            
            
        }  if (i==1) {
            
            NSString *responseString2 = [request responseString];
            UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"HTML" message:responseString2 delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
            [alert show];
            [alert release];
            
        }
        
        
    }
    
}