Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Help stripping tags from RSS feed


Sorry for such a simple question but I'm quite new to TA. I have a js file below pulling in an XML feed. I want to use the strip_tags.js file from KitchenSink in order to strip out an a tag with an image in it but I'm at a loss where to put it! Any help gratefully received! Thanks.


— asked August 10th 2010 by Andy Whitwood
  • parsing
  • rss

3 Answers

  • Just include the strip_tags.js file at the top of your code like so:


    The main thing to make sure of here is that you have the path correct relative to whatever .js file you're working in.

    When you call the strip_tags() function, you have to specify the tags you want to keep. Like this…

    description = strip_tags(description, '<p><b><i>');

    That would KEEP all the <p>'s, <b>'s, and <i>'s. I made a very slight modification to strip_tags.js so that instead of saying which tags to keep, I tell it which tags to remove. All you really have to do is change this line:

    if (!allowed) {


    if (allowed) {

    So, then say you want to REMOVE the <img> tags and ONLY the <img> tags. You'd write:

    description = strip_tags(description, '<img>');

    (For my own sanity, I also changed all refrences of "allowed_tags" to "disallowed_tags")


    — answered August 10th 2010 by E Telford
    1 Comment
    • Sorry but where would I add the 'description' section you mention above…
      I'm guessing somewhere in here?

      var description = item.getElementsByTagName("description").item(0).text;
      var row = Ti.UI.createTableViewRow({height:85, backgroundImage:'../images/grad.png', selectedBackgroundColor:'#333333'});

      — commented August 10th 2010 by Andy Whitwood
  • I'm having the same issue here too. I have the file included just like it shows in the rss.js example in the KS, but it doesn't strip any tags. Anyone out there that has used this file?


    — answered August 10th 2010 by Dave Devitt
  • worked like a charm….thanks for the help!

    — answered August 10th 2010 by Dave Devitt
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.