Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Remove HTML tags from XML output

ServiceNow SA
Kilo Guru

Hi team,

I have XML code to display some data in HTML knowledge article template.

However the output has <div> tags in it. How can i remove those?

Here is the sample code:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate object="true" var="jvar_statements">


var stmt = new GlideRecord('sn_compliance_policy_statement');
var qr = stmt.addJoinQuery('sn_compliance_m2m_policy_policy_statement', 'sys_id', 'content');
qr.addCondition('document', current.sys_id + '');
qr.orderBy('order');
stmt.query();

stmt;

<p>${current.policy_text}</p>

<j:while test="${jvar_statements.next()}">
<p style="font-weight: bold;"> ${jvar_statements.getValue('name')}</p>

<p>${jvar_statements.getValue('description')}</p>

</j:while>
</j:jelly>

Now the "description" is a HTML field and i need exactly the HTML output.

Expected:

Control: <<Some content>>
 
A. <<Some content>>
 
1. <<Some content>>
 
2. <<Some content>>
 
Actual:
 
<div>Control: <<Some content>> <div></div><div></div>A. <<Some content>><div></div>1. <<Some content>><div></div>2. <<Some content>><div></div>
 
Any help pls.
1 ACCEPTED SOLUTION

This is Jelly so you need to escape all of the chars that it does not like.  Here is a place to start with your reading.

https://docs.servicenow.com/bundle/newyork-application-development/page/script/server-scripting/refe...

 

View solution in original post

8 REPLIES 8

Hi 

Try using it in the <g:evaluate> block.

Not working!

This is Jelly so you need to escape all of the chars that it does not like.  Here is a place to start with your reading.

https://docs.servicenow.com/bundle/newyork-application-development/page/script/server-scripting/refe...