问题
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.
回答1:
You could use JavaScript to get the element...
NSString *javaScript = @"document.getElementById( YOU ID );";
NSString *response = [webView stringByEvaluatingJavaScriptFromString:javaScript];
Hope that helps...
回答2:
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.
来源:https://stackoverflow.com/questions/19096705/how-to-get-all-html-elements-in-uiwebview