<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove HTML tags from a string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441418#M1412360</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;                  Hope this code solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA : ipstr TYPE string,
       opstr1 type string,
       opstr2 type string,
       opstr TYPE string,
       len TYPE i VALUE 0,
       ch TYPE char1,
       num TYPE i VALUE 0,   "No of Characters to be taken
       pos TYPE char3,      "Position of Char in the Input String
       count(3) type n.
*Input string
ipstr = '&amp;lt;p style="something"&amp;gt;Hello &amp;lt;strong&amp;gt;World&amp;lt;/strong&amp;gt;!&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;I need the data.&amp;lt;/br&amp;gt;How are you?'.

len = STRLEN( ipstr ).
  DO len TIMES.
*Char by Char
  ch = ipstr+pos(1).
  pos = pos + 1.
*Scan each char in input String for "&amp;gt;"
  FIND '&amp;gt;' IN ch IGNORING CASE.
  IF sy-subrc = 0.
count = count + 1.
endif.
  FIND '&amp;lt;' IN ch IGNORING CASE.
    IF sy-subrc = 0.
count = count + 1.
endif.
enddo.

 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vasuki S Patki on Dec 17, 2009 4:56 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Dec 2009 10:58:13 GMT</pubDate>
    <dc:creator>former_member206377</dc:creator>
    <dc:date>2009-12-17T10:58:13Z</dc:date>
    <item>
      <title>Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441413#M1412355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a string that contains a couple of HTML or XHTML tag, for example&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; lv_my_string = '&amp;lt;p style="something"&amp;gt;Hello &amp;lt;strong&amp;gt;World&amp;lt;/strong&amp;gt;!&amp;lt;/p&amp;gt;'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;For a special use case, I want to remove all HTML from that string and process only the plain text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; lv_my_new_string = 'Hello World!'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any method, function module, XSLT or anything else for that already?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2009 14:23:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441413#M1412355</guid>
      <dc:creator>daniel_humberg</dc:creator>
      <dc:date>2009-12-16T14:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441414#M1412356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HRDSYS_CONVERT_FROM_HTML&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;SOTR_TAGS_REMOVE_FROM_STRING&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2009 14:25:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441414#M1412356</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2009-12-16T14:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441415#M1412357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check  &lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="7913089"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2009 15:04:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441415#M1412357</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-16T15:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441416#M1412358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the followig FMs:&lt;/P&gt;&lt;P&gt;1. SOTR_TAGS_REMOVE_FROM_STRING&lt;/P&gt;&lt;P&gt;2. SWA_STRING_REMOVE_SUBSTRING&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 00:54:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441416#M1412358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-17T00:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441417#M1412359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thx for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. SOTR_TAGS_REMOVE_FROM_STRING =&amp;gt; nice but not perfect. It removes also single characters like "&amp;lt;" and "&amp;gt;" from the text. I would have to encode them before, right?&lt;/P&gt;&lt;P&gt;2. HRDSYS_CONVERT_FROM_HTML =&amp;gt; returns only an empty table in my test&lt;/P&gt;&lt;P&gt;3. SWA_STRING_REMOVE_SUBSTRING =&amp;gt; what kind of delete pattern would I use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 09:48:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441417#M1412359</guid>
      <dc:creator>daniel_humberg</dc:creator>
      <dc:date>2009-12-17T09:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441418#M1412360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;                  Hope this code solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA : ipstr TYPE string,
       opstr1 type string,
       opstr2 type string,
       opstr TYPE string,
       len TYPE i VALUE 0,
       ch TYPE char1,
       num TYPE i VALUE 0,   "No of Characters to be taken
       pos TYPE char3,      "Position of Char in the Input String
       count(3) type n.
*Input string
ipstr = '&amp;lt;p style="something"&amp;gt;Hello &amp;lt;strong&amp;gt;World&amp;lt;/strong&amp;gt;!&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;I need the data.&amp;lt;/br&amp;gt;How are you?'.

len = STRLEN( ipstr ).
  DO len TIMES.
*Char by Char
  ch = ipstr+pos(1).
  pos = pos + 1.
*Scan each char in input String for "&amp;gt;"
  FIND '&amp;gt;' IN ch IGNORING CASE.
  IF sy-subrc = 0.
count = count + 1.
endif.
  FIND '&amp;lt;' IN ch IGNORING CASE.
    IF sy-subrc = 0.
count = count + 1.
endif.
enddo.

 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vasuki S Patki on Dec 17, 2009 4:56 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 10:58:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441418#M1412360</guid>
      <dc:creator>former_member206377</dc:creator>
      <dc:date>2009-12-17T10:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441419#M1412361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
  split ipstr at '&amp;gt;' INTO opstr opstr1.
    DO count TIMES.
  split opstr1 at '&amp;lt;' into opstr opstr1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 11:04:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441419#M1412361</guid>
      <dc:creator>former_member206377</dc:creator>
      <dc:date>2009-12-17T11:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441420#M1412362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
 concatenate opstr2 opstr into opstr2.
  split opstr1 at '&amp;gt;' into opstr opstr1.

ENDDO.
  WRITE :/ opstr2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please &lt;STRONG&gt;combine&lt;/STRONG&gt; all  the above posted code and hope thsi helps you..   &lt;/P&gt;&lt;P&gt;I tested it with this code and works fine..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 11:32:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441420#M1412362</guid>
      <dc:creator>former_member206377</dc:creator>
      <dc:date>2009-12-17T11:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441421#M1412363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use some Regular Expressions -:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: message TYPE string.

message = '&amp;lt;p style="something"&amp;gt;Hello &amp;lt;strong&amp;gt;World&amp;lt;/strong&amp;gt;!&amp;lt;/p&amp;gt;'.

REPLACE ALL OCCURRENCES OF REGEX '&amp;lt;[a-zA-Z\/][^&amp;gt;]*&amp;gt;' IN message with space.
WRITE:/ message.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2009 16:24:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441421#M1412363</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-17T16:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441422#M1412364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;I tried using the FM (SWA_STRING_REMOVE_SUBSTRING) but I guess it is expecting a particular pattern which is not so apparent in your case. Iu2019ve written a small piece of code which you can try using in a FM or a PERFORM and that should do the trick. Please let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PARAMETER: P_LINE(100).

TYPES: BEGIN OF TY_LINE,
         LINE(100),
       END OF TY_LINE.

DATA: T_LINE TYPE STANDARD TABLE OF TY_LINE,
      WA_LINE LIKE LINE OF T_LINE.

DATA: W_LINE(100),
      W_LEN(100),
      W_COUNT TYPE I,
      W_FLAG,
      W_FLAG1,
      W_I TYPE I.

W_COUNT = STRLEN( P_LINE ).

DO W_COUNT TIMES.
  IF P_LINE+W_I(1) = '&amp;lt;'.
    W_FLAG = 1.
    W_I = W_I + 1.
    IF NOT WA_LINE-LINE IS INITIAL.
      APPEND WA_LINE-LINE TO T_LINE.
      CLEAR WA_LINE.
    ENDIF.
    CONTINUE.

  ELSEIF P_LINE+W_I(1) = '&amp;gt;'.
    W_FLAG = 0.
    W_I = W_I + 1.
    CONTINUE.
  ENDIF.

  IF W_FLAG = 1.
    W_I = W_I + 1.
    CONTINUE.
  ELSE.
    CONCATENATE WA_LINE-LINE P_LINE+W_I(1) INTO WA_LINE-LINE.
    W_I = W_I + 1.
  ENDIF.

ENDDO.

LOOP AT T_LINE INTO WA_LINE.
  CONCATENATE W_LINE WA_LINE-LINE INTO W_LINE SEPARATED BY SPACE.

ENDLOOP.

SHIFT W_LINE LEFT DELETING LEADING SPACE.
WRITE: W_LINE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;p style="something"&amp;gt;Hello &amp;lt;strong&amp;gt;World&amp;lt;/strong&amp;gt;!&amp;lt;/p&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Output: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;HELLO WORLD ! &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pritam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Dec 2009 18:19:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441422#M1412364</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-18T18:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441423#M1412365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;I realized i made a typo while copying the code. The Do~Enddo code would go like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DO W_COUNT TIMES.
  IF P_LINE+W_I(1) = '&amp;lt;'.
    W_FLAG = 1.
    W_I = W_I + 1.
    CONTINUE.
  ENDIF.
 
  IF P_LINE+W_I(1) = '&amp;gt;'.
    W_FLAG = 0.
    W_I = W_I + 1.
    CONTINUE.
  ENDIF.

  IF W_FLAG = 1.
    W_I = W_I + 1.
    CONTINUE.
  ELSE.
    CONCATENATE WA_LINE-LINE P_LINE+W_I(1) INTO WA_LINE-LINE.
    W_I = W_I + 1.
  ENDIF.
 ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try this let me know if you have any questions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2009 07:34:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441423#M1412365</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-19T07:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove HTML tags from a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441424#M1412366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;There is some formatting issue while posting this code using the symbol {&amp;lt;}. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically inside the Do loop the if condition is to be written twice. First time to check for {&amp;lt;} and if satisafied w_flag is set to "1" and second time to check for "&amp;gt;" and if satisfied w_flag is set to "0".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2009 07:57:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-html-tags-from-a-string/m-p/6441424#M1412366</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-12-19T07:57:39Z</dc:date>
    </item>
  </channel>
</rss>

