Hi, I'm fairly new to iphone programing and i have been trying to make a small app to simply load a website in a UIWebView and then extract parts of data into a UITextView below the webview.
I have been trying to use the code line stringByEvaluatingJavascriptFromString, however, i cannot seem to be able to get the data from webview. Below is my .h and .m codes. So far i am able to successfully load the site in the webview, but not extract the code.
Code:
#import <UIKit/UIKit.h>
@interface webappViewController : UIViewController {
IBOutlet UIWebView *webview;
IBOutlet UITextView *textview;
}
@property(nonatomic, readonly) UIWebView *webview;
@property(nonatomic, retain) UITextView *textview;
@end
#import "webappViewController.h"
@implementation webappViewController
@synthesize webview;
@synthesize textview;
- (void)viewDidLoad {
NSString *urladdress = @"http://members.iinet.net.au/~siegwart/Untitled-1.html";
NSURL *url = [NSURL URLWithString:urladdress];
NSURLRequest *requestobj = [NSURLRequest requestWithURL:url];
[webview loadRequest:requestobj];
NSString *mytext = [webview stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContents"];
textview.text = mytext;
}