$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: true, vro: true, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Oct 28, 2013 at 05:48 PM

    Hello,

    I think there is no regex expression to remove these HTML characters (at-least i can't able to find it), so use old fashioned way of removing these characters😊

    Input value is : Input

    In case u have multiple values possible for a given field then add one more for loop at the top.

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Oct 28, 2013 at 05:53 PM

    Hi Vasanth,

    Use standard replace function with below strings and replace with blank character.

    <p align="center">

    <font color="Green" face="arial" size="6">

    </font>

    <u>

    </u>

    </p>

    This is a work around for UDF.

    Regards,

    Pranav

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2013 at 05:21 PM

    Hello,

    IMO, u should have asked sender system to remove these characters?

    Having said that, in PI there is no standard function to remove HTML characters so UDF is the only option.

    May be u can search google for regex expressions (i am not sure if there are any) ?

    Thanks

    Amit Srivastava

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2013 at 05:27 PM

    hi Vasant,

    AFAIK, this is to be done using a UDF.

    Ambrish

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 28, 2013 at 05:31 PM

    hi Vasant,

    I agree with the experts. There doesnt seems to be any standard way to remove it but probably you can deal with UDF.

    Please let us know if you need help regarding UDF.

    thanks and regards,

    Praveen T

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 28, 2013 at 05:44 PM

    Hi All,

    Thanks for the reply

    Can you please tell me how to create a udf

    Regards,

    Vasant

    Add comment
    10|10000 characters needed characters exceeded