Write XML file

Hi,

I search a way to write or convert all non permitted XML char and write a standard XML file (not pList).
Any idea about some Cocoa command that execute the chars transformations?
I search Cocoa because with AS this can be probably more slower.
The input text is UTF text get from InDesign box.

Ame

Maybe not the real answer to your question, but an idea how to. This method does the reverse of what you are asking.
I hope this is of a little help.


-(NSString *)stringByReplacingXmlEntities
{
	NSMutableString	 *input = [self mutableCopyWithZone: nil];
	
	NSRange lt =  [input rangeOfString:@"<"];
	NSRange gt = [input rangeOfString:@">"];
	NSRange qt = [input rangeOfString:@"""];
	NSRange ps = [input rangeOfString:@"'"];
	NSRange amp = [input rangeOfString:@"&"];
	
	if (lt.location != NSNotFound) {
		NSString* temp1 =  [input stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
		[input setString:temp1];
		}
	if (gt.location != NSNotFound) {
		NSString* temp1 = [input stringByReplacingOccurrencesOfString:@">" withString:@">"];
		[input setString:temp1];
	}
	if (qt.location != NSNotFound) {
		NSString* temp1 = [input stringByReplacingOccurrencesOfString:@""" withString:@"\""];
		[input setString:temp1];
	}
	if (ps.location != NSNotFound) {
		NSString* temp1  = [input stringByReplacingOccurrencesOfString:@"'" withString:@"'"];
		[input setString:temp1];
	}
	if (amp.location != NSNotFound) {
		NSString* temp1  = [input stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
		[input setString:temp1];
	}
	 return [NSString stringWithString: input];
}

You probably want CFXMLCreateStringByEscapingEntities() and CFXMLCreateStringByUnescapingEntities(), but I think you’ll have to use Objective-C – they’re functions I don’t think you can use form ASObjC.