Could someone who is familiar with webkit please explain or point me in the right direction as to why the following code does not work
What i'm trying to do is load a page, have webkit parse it and simply print out the title.
Here is what i've got:
#include <iostream>
#include <WebKit/WebKit.h>
using namespace std;
/*
Seek Help
*/
int main (int argc, char * const argv[]) {
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
WebFrame * mainFrame;
WebView * view = [[WebView alloc] initWithFrame: NSMakeRect (0,0,640,480)];
mainFrame = [view mainFrame];
NSString * url = @"http://test.com";
[[view mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
NSString * data = @"<html><head><title>testing</title></head><body>tester</body></html>";
[[view mainFrame] loadHTMLString:data baseURL: nil];
// NSString * urlString = [[NSString alloc] initWithUTF8String:"<html><head><title>Hello World</title></head><body><p>My first Web page.</p></body></html>"];
//[[view mainFrame] loadHTMLString:urlString baseURL:nil];
NSString * outerHtml = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] innerHTML];
cout << "Html: " << [outerHtml UTF8String] << endl;
NSString * title = [view mainFrameTitle];
cout << "title: " << [title UTF8String] << endl;
[autoreleasepool release];
return 0;
}
The output is both html and title are blank
Thank You for reading