Help stripping tags from RSS feed
Hi,
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.
http://pastie.org/1083724
3 Answers
-
Just include the strip_tags.js file at the top of your code like so:
Ti.include('path/to/strip_tags.js');
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) {
to:
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")
[http://phpjs.org/functions/strip_tags:535]
-
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?
TIA
-
worked like a charm….thanks for the help!