Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

sfloberg
New Contributor

Remove HTML-code from database

I read data to a Qlik Sense application from a database that is populated by a textbox. The user can make the text bold and so on.

Is there any way to remove the HTML-code from the content? I don't want the HTML tags in my field in the Qlik Sense application.

1 Reply
MVP
MVP

Re: Remove HTML-code from database

This script snippet can give you an idea on how you can dynamically populate a mapping table with HTML tags and use that with MapSubstring() to strip them out:

TEST:

LOAD RecNo() AS RecNo,

html_field

INLINE [

html_field

'<body><p>Hello!</p><p></p><p>DATA TEST DATA TEST </p><p></p><p>TESTING THIS OTHER SEGMENT.</p><p> also this one in lower case</p><p></p><p>lots of different types of html tags <span test="test" __test_macro="testmac" class="test_macro" src="test.gif"></span></p></body>'

];


HTML_TAG_MAP:

MAPPING LOAD DISTINCT

'<' & TextBetween('<' & SubField(html_field, '<'),'<','>') & '>' AS HtmlTag,

'' AS Substitute

RESIDENT

  TEST;


JOIN (TEST)

LOAD

  RecNo,

  MapSubstring('HTML_TAG_MAP', html_field) as Field_Cleansed

RESIDENT

  TEST

ORDER BY

  RecNo;


This script was created by someone else in this thread: Removing HTML markup code which did this for QlikView...

I tested it in Qlik Sense and it works equally well there.

Community Browser