android – remove html tags from the json response-ThrowExceptions

Exception or error:

Hi from the below response want to remove

unwanted tags and blank spaces and want to bold display heading should be bold

can any one help me
String termsnconditions=listSalesStageOpportunity.get(position).getTermsnconditions();

Resonse :

"<p>Price: Price offered for the above configuration only.<br />
\r\nTax:Above mentioned price is inclusive of custom duty, Excise, Freight up to site and GST.<br />
\r\nLocal levies such as Octroi / Entry tax if any, the same will be at Purchaser’s account.<br />
\r\nValidity: This price is valid for a week from the date of the proposal.<br />
\r\nPayment: 100% Advance<br />
\r\nInstallation  : Genworks Specialist / Representative at your site will give Training and Installation without any additional cost.<br />
\r\nWarranty: 12 Months from the date of installation or 13 Months from the date of Invoice. Warraty will be provided for hardware items only and consumables items are not a part of warranty.</p>"

String terms=termsnconditions.replaceAll("<p>","");
                terms_condition.setText(terms);
How to solve:
String terms = "";
 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
  terms = (Html.fromHtml(termsnconditions ,Html.FROM_HTML_MODE_LEGACY));
 } else {
 terms = (Html.fromHtml(termsnconditions ));
}

use your string like this

Leave a Reply

Your email address will not be published. Required fields are marked *