• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Removing html tags from RSS/XML Text

Contributor ,
Nov 07, 2008 Nov 07, 2008

Copy link to clipboard

Copied

I have managed to get rid of unwanted line breaks and returns in the RSS text I am bringing in to populate my dynamic text fields. The Dynamic Text fields are set up not to render text as html, are multiline and have the fonts embedded. I keep seeing things like, <p style=""> at the beginning of the story or <THI.TO> in the middle of the story. Is there any way of deleting anything that appears as <anything> and replace with a space? Here is the code I am currently using to eliminate the line breaks. Also is there any way of turning hyphenation on? Forrest
TOPICS
ActionScript

Views

484

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2008 Nov 08, 2008

Copy link to clipboard

Copied

An easy solution to the problem is to have an off-stage field that renders as html, and then take the text from it. Like this:

htmlfield.htmlText = somehtml;
var justthetext = htmlfield.text;

Then get rid of the line breaks in the justhetext variable.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2008 Nov 08, 2008

Copy link to clipboard

Copied

LATEST
I think a better approach is to use regular expressions:

var regexPattern:RegExp = /<.*?>|\n|\r/g;
var str:String = "<br />one line<p style=''>ano\rther line </p>third \nline.";
trace(str.replace(regexPattern, "GOTCHA"));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines