Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Remove HTML characters

Hi Experts,

I want to remove HTML characters which are coming in one of the fields in XML file. For example:

Input field:

<Text><p align="center">Input Contains<font color="Green" face="arial" size="6">Test-</font>HTMl characters- <u>which needs to be removed- </u> Thanks </p></Text>

Output:

<Text>I want to remove HTML characters which are coming in one of the fields in XML file<|Text>

So is there any standard function which could help me in removing HTML characters or do I need to write a UDF for this? Please help.

Regards

Vasant

Former Member
replied

Hello,

My mistake...i haven't tested above code.

Please check this (now i have tested it and it should work fine ):

Input will be var1

Execution type: All values of a context

under import statements -> add one more entry and paste-> java.text.*

String output="";

boolean intag =false;

String input = var1[0];

for (int i=0; i < input.length(); ++i)

{

if (!intag && input.charAt(i) == '<')

{

intag = true;

continue;

}

if (intag && input.charAt(i) == '>')

{

intag = false;

continue;

}

if (!intag)

{

output = output + input.charAt(i);

}

}  

result.addValue(output);

Thanks

Amit Srivastava

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question