21 Aug 2009, 04:15
_me02_pragsmall

Christopher Tysh (49 posts)

I’ve got some HTML coming in that contains some ` <DIV>tags. I would like to remove these <DIV> tags from the HTML, but the problem is that some of the <DIV> tags have classes or ids defined in them. I can replace the <DIV` portion of the tag, but since there is no wildcard allowed, I don’t know how to get rid of all these tags.

Basically what I would like to do: ` mystring = [mystring stringByReplacingOccurrencesOfString:@”<div*>” withString:@””]; `

Any ideas would be great.

21 Aug 2009, 14:36
_me02_pragsmall

Christopher Tysh (49 posts)

I’m looking at NSPredicate but not sure how / if I can work with this to make it do what I’m trying to acheive.

21 Aug 2009, 17:37
Biopic_100x100_pragsmall

Bill Dudney (917 posts)

Hi Christopher,

You have to search for <div then when its found find > and nuke everything between them.

indexOfCharacter: or something like that would be the way to go.

Good luck!

21 Aug 2009, 18:38
_me02_pragsmall

Christopher Tysh (49 posts)

I found a couple of functions online that might work out. If these don’t work I’m going to try something with finding the Range of the characters and then removing characters in that rage, or keep hacking at NSScanner.

http://www.alexrude.com/articles/Strip-HTML-Tags-in-Cocoa-Objective-C http://www.rudis.net/content/2009/01/21/flatten-html-content-ie-strip-tags-cocoaobjective-c

22 Aug 2009, 23:53
_me02_pragsmall

Christopher Tysh (49 posts)

So you guys know, the code on this page http://www.rudis.net/content/2009/01/21/flatten-html-content-ie-strip-tags-cocoaobjective-c

works to remove the HTML Tags from an NSString.

  You must be logged in to comment