Easily Convert HTML to Plain Text in a Business Process – Script Guide

Hello, community!

I’ve created a script that helps convert HTML text from a database into plain text.
 

To achieve this, you’ll need to add two libraries to the business process:


 

Then, use the following script task:



string texthtml = Get("texthtml");

if (string.IsNullOrWhiteSpace(texthtml)) {
   Set("DecodedHtmlText", string.Empty);
} else {
   // Remove HTML tags
   string text = Regex.Replace(texthtml, "<.*?>", string.Empty);

   // Decode HTML entities (e.g., & -> &)
   text = WebUtility.HtmlDecode(text);

   // Store the result in a business process variable
   Set("DecodedHtmlText", text);
}
 

return true;

* texthtml - parametr where our html text stored
* DecodedHtmlText - text type parametr to set text



I hope this will be useful!

Like 1

Like

Share

0 comments
Show all comments