Reputation: 133
I have a string of HTML that was parsed by libxml2.dylib that looks like:
Hello,<br />\n<br />\nThis is almost HTML.<br />\n<br />\n
I've unsuccessfully tried to display certain strings parsed from the XML in a WebView; I'm hoping there's a simple way to do it such as how an HTML page is displayed in my Cocoa application:
HTMLView.h
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface htmlView : NSObject {
IBOutlet WebView * webview;
}
-(IBAction) showHTML:(id) sender;
@end
HTMLView.m
#import "HTMLView.h"
@implementation htmlView
-(IBAction) showHTML:(id) sender
{
[[webview mainFrame] loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://www.example.com"]]];
NSString * string = @"<br>test</br>";
[self loadHTMLString:string baseURL:(NSURL *)baseURL];
}
-(void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL {
}
@end
Upvotes: 2
Views: 3180
Reputation: 563
try this... [[aWebView mainFrame] loadHTMLString:aString baseURL:nil];
Upvotes: 4
Reputation: 4520
I've unsuccessfully tried to display certain strings parsed from the XML in a WebView
How did you try to display the strings and what was the problem? I think
-(void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
Might be what you need...!?
Edit: You have to call the method on your webview! What you did now is implementing your own loadHTMLString method in your viewController. Which would be fine if it did anything and did call loadHTMLString on the webview at some point.
[self.webView loadHTMLString....]
I think you have to familiarise yourself a bit more with objective-c.
Upvotes: 1