// // NSString+XMLSerializableSupport.m // active_resource // // Created by James Burka on 1/6/09. // Copyright 2009 Burkaprojects. All rights reserved. // #import "NSString+XMLSerializableSupport.h" #import "NSObject+XMLSerializableSupport.h" #import "NSString+GSub.h" @implementation NSString(XMLSerializableSupport) + (NSString *)fromXmlString:(NSString *)aString { NSDictionary* escapeChars = [NSDictionary dictionaryWithObjectsAndKeys:@"&",@"&",@"\"",@""",@"'",@"'" ,@"<",@"<",@">",@">",nil]; return [aString gsub:escapeChars]; } - (NSString *)toXMLValue { NSString *temp = [self gsub:[NSDictionary dictionaryWithObject:@"&" forKey:@"&"]]; NSDictionary* escapeChars = [NSDictionary dictionaryWithObjectsAndKeys:@""",@"\"",@"'",@"'",@"<",@"<",@">",@">",nil]; return [temp gsub:escapeChars]; } - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions withTranslations:(NSDictionary *)keyTranslations { return [[self class] buildXmlElementAs:rootName withInnerXml:[self toXMLValue]]; } @end