Skip to Content

Gareth53.co.uk - the online home of Gareth Senior

Stripping HTML

2:16p.m., Sat 6 Jan 2007

Some while ago I was asked to build a flash widget that used an XML feed as its datasource. Annoyingly, the XML feed had html tags in there to format the data. Curses! So I wrote this little actionscript function to strip the HTML. It works in javascript too and I've re-used it a few times since....

function stripHtml(str) {
while ((str.indexOf('<')!=-1) && (toStrip.indexOf('>')!=-1)) {
str = str.slice(0,str.indexOf('<')) + str.slice((str.indexOf('>') + 1),str.length);
}
return str; }

Latest Posts

  • Muppets Birthday Card

    5:47p.m., 28 Nov

    Emma loves The Muppets. She even has her own Muppet who we call Emma Too and who was born at ...
  • Detecting Online Status In The Browser

    11:55a.m., 28 Nov

    I was just heading into a meeting when I was asked how our (mostly web-based) iOS application was going to ...
  • Dropping Support for Internet Explorer 6

    2:37p.m., 11 Oct

    Microsoft's Internet Explorer 6 has long been the bane of every front-end developer's life. It's a 10-year old browser - ...
  • Xfm Buzz - A Radio Hack

    1:15p.m., 31 May

    At Global Towers we developers have 10% time to go away and hack at something that might, ultimately, bring value ...

Blog Categories