PHP has strip_tags function which strips HTML and PHP tags from a string.
Does Android have a way to escape html?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The solutions in the answer linked to by @sparkymat generally require either regex – which is an error-prone approach – or installing a third-party library such as jsoup or jericho. A better solution on Android devices is just to make use of the Html.fromHtml() function:
This uses Android’s built in Html parser to build a
Spannedrepresentation of the input html without any html tags. The “Span” markup is then stripped by converting the output back into a string.As discussed here, Html.fromHtml behaviour has changed since Android N. See the documentation for more info.