• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing HTML Tags
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing HTML Tags


  • Subject: Re: Removing HTML Tags
  • From: Dan Wood <email@hidden>
  • Date: Mon, 29 Apr 2002 19:52:52 -0700

I do something kind of evil: I "render" the HTML into an attributed string, and then take the flat string out of that. Probably a bit inefficient, but it seems to work. Plus, it renders the &-sequences as well..

- (NSString *) flattenHTML
{
NSString *result = self;
NSAttributedString *attrString;
NSData *theData = [self dataUsingEncoding:NSMacOSRomanStringEncoding]; // encoding for below to work
if (nil != theData)
{
attrString
= [[[NSAttributedString alloc]
initWithHTML:theData documentAttributes:nil] autorelease];
result = [attrString string];
}
return result;
}




On Monday, April 29, 2002, at 05:12 pm, email@hidden wrote:

Hi folks! I'm looking for a way to remove HTML tags from an NSString. I think it might be possible via an NSScanner, but I'm not sure how to go about it. Any suggestions?

Owen Anderson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.



--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Removing HTML Tags (From: email@hidden)

  • Prev by Date: Flood filing an NSImage
  • Next by Date: DOCK: CFMessagePortSendRequest returned (-1|-2)
  • Previous by thread: Removing HTML Tags
  • Next by thread: Refresh woes for custom OGL pane
  • Index(es):
    • Date
    • Thread