Skip to main content
Inspiring
November 7, 2008
Question

Removing html tags from RSS/XML Text

  • November 7, 2008
  • 1 reply
  • 552 views
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
This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
November 8, 2008
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.


Inspiring
November 8, 2008
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"));