2 Replies Latest reply on Mar 6, 2007 12:41 PM by tonyhigham

    remove html tags from a string

    Lujunq
      Hi, is there a simple way to get rid of html tags present on a string? What about special chars encoded? What I want to do is to change

      <p>Hi, this is a <b>tagged html</b> text with some special chars: &aacute;&Aacute;&ccedil;...</p>

      into this:

      Hi, this is a tagged html text with some special chars: áÁç...

      The formatting information, like the bold on text above, is not important to me. I just want the plain text with special chars converted.
        • 1. Re: remove html tags from a string
          Level 7
          Lujunq,

          > Hi, is there a simple way to get rid of html tags present on
          > a string?

          You betcha. Just route the string with those tags to the TextField.text
          property of your text field, rather than its TextField.htmlText property.

          > What about special chars encoded? What I want to do is
          > to change
          > <p>Hi, this is a tagged html text with some special chars:
          > &aacute;&Aacute;&ccedil;...</p>

          Ah, those are HTML entities, and Flash only supports very few of them.
          Search "About supported HTML entities" in the documentation for the full
          (very short) list.

          > The formatting information, like the bold on text above, is
          > not important to me. I just want the plain text with special
          > chars converted.

          HTML formatting is required to translate the few HTML entities
          supported. If you drop the HTML formatting, you'll lose the formatting, but
          you'll also lose the entity conversion. It would be tedious, but you would
          have to loops through your string characters looking for HTML entities and
          replace them one by one.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: remove html tags from a string
            tonyhigham Level 1
            A fairly painless solution to stripping out html tags is below. After you strip them out, you'll still need to take care of those special characters. You can do that with the prototypable method outlined here:
            http://www.actionscript.org/forums/showthread.php3?t=111952