api - Accessing DOM Webkit Objective C -
Anyone who is familiar with webkit please explain or point me in the right direction as the following code does not work
I am trying to load a page, parsing webkit and just printing the title.
What do I have here:
#include & lt; Iostream & gt; # Include & lt; WebKit / WebKit.h> using namespace std; / * Get help * / integer main (int argc, char * [] argv constant) {NSAutoreleasePool * autoreleasepool = [[NSAutoreleasePool alloc] init]; Webframe * mainframe; Webview * View = [[WebWeb Alok] initWithFrame: NSMakeRect (0,0,640,480)]; Mainframe = [see main frame]; NSString * url = @ "http://test.com"; [[See mainframe] loadRequest: [NSRR request request with url: [NSUr URL youth string: url]]]; NSString * data = @ "from gt; top & gt; & gt; test & gt; test & lt; / title & gt; & lt; / head & gt; & lt; body & Gt; Tester & lt; / body & gt; & lt; / html & gt; "; [[View key frame] Load HTML string: Data base URL: zero]; // NSString * urlString = [[NSString alloc] initWithUTF8String: "& lt; html> gt; top & gt; & gt; title & gt; hello world & lt; / title & gt; & lt; / Head>
my first web page. "]; // [[see main frame] Load HTML string: urlString baseURL: zero]; NSString * External HTML = [(DOMHTMLElement *) [[see main view] DOMDocument] Document document] Inner HTML]; Cout & lt; & Lt; "HTML:" & lt; & Lt; [External HTML UTF 8 string] & lt; & Lt; Endl; NSString * title = [see main frame title]; Cout & lt; & Lt; "Title:" & lt; & Lt; [Title UTF8String] & lt; & Lt; Endl; [Autoreilpool release]; Return 0; Output is both HTML and the title is empty
Thanks for reading
This is because WebKit depends on RunLoop does not work to load content, even if it is just static content
You should add a standard run loop such as:
while (done!) {Pool = [[NSAUTOIPUL ALLOCK] IIT]; [[NSRunLoop currentRunLoop] Runmod: NSDFaultRonoopodd before date: [NSDT remote paste]]; [Bridge release]; } and that you can set it as WebFrameLoadDelegate ( webView.frameLoadDelegate = thatObject ), and create a custom square in - (zero ) WebView: (WebView *) Sender didFinishLoadForFrame: (webframe *) frame callback You should be able to reach DOM. Also, when loaded, set the done flag to yes.
Comments
Post a Comment