How to parse HTML tags information into normal text without using the [code][/code]

sree06
Tera Contributor

Hi All,
How to parse HTML tags information into normal text without using the [code][/code].

4 REPLIES 4

Maik Skoddow
Tera Patron

Hi @sree06 

you can use

var strPlainText = new GlideSPScriptable().stripHTML(yourHtmlStr);

Maik

ChrisBurks
Giga Sage

Hi @sree06 ,

Just for awareness in case the html used is helping in formatting the data (tags like "p" for paragraphs or even "div" or "br" ), the formatting will be lost. If that is the case then you might want to convert some of those tags to text representation before stripping. For example changing out break tags <br /> or ending div "</div>" and  paragraph "</p>" tags  with "\n". 

This way you won't have a bunch of garbled up text.

Would love to see an example of that, @sree06.

Prathamesh G
Kilo Sage

Hello @sree06

 

You can use decodeHTML() functionality in servicenow to convert your HTML information into the Normal Text.

 

Below I have attached the link for more reference: 

https://www.servicenow.com/community/developer-forum/removing-html-tags/m-p/2522727

 

 

If my answer helps with your issue, Please mark the answer as Accepted Solution and mark it as Helpful.

 

Thank you !

Prathamesh