Kirubachari
Kirubachari

Reputation: 688

How to get all HTML elements in UIWebView

I have loaded an UIWebView with .rtf file.

Now, I want to get all HTML elements or elements present inside the UIWebView. Is there any method available to get it?

Thanks for your answers.

Upvotes: 1

Views: 3353

Answers (2)

Georg
Georg

Reputation: 3920

You could use JavaScript to get the element...

NSString *javaScript = @"document.getElementById( YOU ID );";
NSString *response = [webView stringByEvaluatingJavaScriptFromString:javaScript];

Hope that helps...

Upvotes: 3

micantox
micantox

Reputation: 5616

You can get all of the HTML content of your UIWebView with the call:

NSString *yourHTMLSourceCodeString = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];

After this it's up to you.

Upvotes: 3

Related Questions