How to get all HTML elements in UIWebView

一笑奈何 提交于 2019-12-11 07:39:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!