Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 208991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:52:31+00:00 2026-05-11T17:52:31+00:00

Could someone who is familiar with webkit please explain or point me in the

  • 0

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

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:52:32+00:00Added an answer on May 11, 2026 at 5:52 pm

    It doesn’t work because WebKit relies on the RunLoop to load content, even if it’s just static content.

    You should add a standard run loop such as:

    while (!done) {
        pool = [[NSAutoreleasePool alloc] init];
        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
                                 beforeDate:[NSDate distantPast]];
        [pool release];
    }
    

    And create a custom class that you set as WebFrameLoadDelegate (webView.frameLoadDelegate = thatObject), and in the - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame callback you should be able to access the DOM. Also when the load is done set the done flag to YES.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please help me in here, I'm just a beginner who want to
Could someone please suggest why this is happening... I’ve got some code to pretty
Could someone please explain why this is happening? var y = new int[]{1,2}; Console.WriteLine(y
I'm not that familiar with COM and was hoping that someone out there, who
If someone could just talk to me and maybe point me in a direction.
Could someone please tell me why this <%= destroy_password_url @user.password_reset_token %> generates http://localhost:3000/api/destroy_password.4G5EoRVYMUAtiIKqOerKsw routes.rb
could someone please tell me what I need to do in order to create
Could someone take a look at this code and find out what's wrong with
Please could someone give me a few tips for creating function pointers for MS
In my facebook page, when someone who's not the admin posts a photo, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.