I am doing the following:
NSData *htmlData = [[NSString stringWithString:sHTML] dataUsingEncoding:NSUTF8StringEncoding];
TFHpple * xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];
NSArray * elements = [xpathParser searchWithXPathQuery:@"//div[@id='column2']"];
if ([elements count] > 0)
{
TFHppleElement * element = [elements objectAtIndex:0];
NSString * sHTMLResult = [element content];
...
}
But, sHTMLResult
(or, [element content]
) is always empty. I have tried [element raw]
but that gives me a string with <!CDATA
tags and carriage returns like &13
. In any case, the CDATA
tags is what causes my html to be invalid when I use raw.
I have done a lot of google searches but they all seem to use [element content]
so I am baffled as to what is wrong and why it does not work for me?