Parsing text/html MKNetworkKit

Discussion in 'iOS Programming' started by nashyo, Jun 29, 2012.

  1. nashyo macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #1
    I'm dying inside. I have been working for literally days and I'm getting no where.

    The following code works fine and the response string shows up in the debugging panel, but I have no idea how to step through the text/html that returns as a responseString (or responseData).

    I'm begging for help. Can someone help me parse html please?

    Code:
    -(MKNetworkOperation*)jobSearchWithGrade:(NSString*)theGrade withSpecialty:(NSString*)theSpeciality withLocation:(NSString*)theLocation
    {
        MKNetworkOperation *op = [self operationWithPath:@"/doctor-jobs/anaesthetics-153/" params:nil httpMethod:@"GET"];
        
        [op onCompletion:^(MKNetworkOperation *completedOperation) {
            NSLog(@"Response: %@", [completedOperation responseString]);
                            
            // do processing here
    
        }onError:^(NSError *error){
            //NSLog(@"failure");
            
            //errorBlock(error);
        }];
        
        [self enqueueOperation:op];
        
        return op;
    }
     
  2. CodeBreaker macrumors 6502

    Joined:
    Nov 5, 2010
    Location:
    Sea of Tranquility
    #2
    It will be great if you can post response headers and the response itself.

    Also, you will look at the response headers only to check for success/failure. The actual response you are looking for will be in responseData. You can convert it to a string using initWithData:encoding of NSString.
     
  3. nashyo thread starter macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #3
    I found TFHpple and this sorted my problem out.
    https://github.com/topfunky/hpple

    I thought I would never find good thrid party code for this task, but I can say this works for me.

    I can access the elements using this. Now I need to become more familiar with XPath to understand how to delve into nodes.

    Thanks.
     

Share This Page