How to convert NSString HTML markup to plain text NSString?

后端 未结 4 616
名媛妹妹
名媛妹妹 2020-12-09 05:37

Been searching the net for an example of how to convert HTML string markup into Plain text.

I get my information from a feed which contains HTML, I the

4条回答
  •  -上瘾入骨i
    2020-12-09 06:00

    If you are using UIWebView then it will be easier to parse HTML to text:

    fullArticle = [webView stringByEvaluatingJavaScriptFromString:@"document.body.getElementsByTagName('article')[0].innerText;"]; // extract the contents by tag
    
    fullArticle = [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerText"]; // extract text inside body part of HTML
    

提交回复
热议问题