Question

How to Get body of content from webpage ?... i want get only text from the body tag all other tags in body should be remove...

can any one help me? Thanks in advance....

No correct solution

OTHER TIPS

First find out what position in the string the body tags are located. Then remove everything before the opening tag and everything after the closing tag using NSString methods.

After that, here's how to strip the HTML tags from your body content:

http://www.objectpark.net/StrippingHTML.html

When you make a call via NSURLConnection you'll receive ASCII text data in the form of NSMutableData from the URL that you've set in NSURLRequest.

From there you'll have to parse it for just the strings, removing all other tags. Perhaps using the tools mentioned in the previous answer.

If you're using a UIWebView to load and display you could use its handy method stringByEvaluatingJavaScriptFromString.

NSString *jsString = @"document.getElementsByTagName('body')[0].innerHTML;";
NSString *contentOfBody = [myWebView stringByEvaluatingJavaScriptFromString:jsString];

This should do the trick in a Web View. Note I might be a tiny bit off with the javescript, but I use this same method in my app and it works beautifully.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top