On Jan 28, 2010, at 3:16 PM, Keith Blount wrote:
So, my question is, what is the best way for me to filter out these
invalid characters from my NSString before I pass it into
NSXMLElement's -initWithName:stringValue: or similar methods, to
avoid creating XML documents that won't open?
Make an NSCharacterSet containing the 'bad' characters.
Make a mutable copy of the string.
Use -[NSString rangeOfCharactersFromSet:options:range:] to iterate
through the string finding the 'bad' characters.
Delete each bad character from the mutable string as you find it.
If there are only a handful of bad characters, it might be more
straightforward to use NSMutableString's
replaceOccurrencesOfString:withString:options:] method instead to
delete them one at a time.
—Jens_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com